I'm currently wondering if when a given string (word), how can I determine if it is a palindrome or not. A palindrome is a word or phrase that is the same if read forward or backward. I think I can solve this by looping through the half the word and comparing each letter with the other half. An example for this could be: (word[0] == word[word.Length-1-0])
would compare the first letter with the last letter of word, and (word[1] == word[word.Length-1-1])
would compare the second letter with the second to last letter.
Example Input could be: racecar
Example Output: True
Am I approaching this problem correctly towards the proper solution?
Here's a bit of I've written down so far.
public bool Test6(string word)
{
for (int i = 0; i < word.Length; i++)
{
if (word[0] == word[word.Length - 1 - 0])
{
}