I am writing code to check for symmetry within a string. I convert to a Char array and then I would like to use the Array.Reverse method. I keep getting a cannot convert type void to Char[]. Any insight would be greatly appreciated my code is as follows.
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
checkPalindrome("aabaa");
}
public static bool checkPalindrome(string inputString)
{
char[] charArray = inputString.ToCharArray();
char[] reverseArray = Array.Reverse(charArray);
Array.Reverse(charArray);
//Console.Write(charArray);
//Console.Write(reverseArray);
if (charArray = Array.Reverse(charArray))
{
return true;
}
else
{
return false;
}
}
}
}
Array.Reversereturnsvoid, so neither the assignment nor the comparison will work.Array.Reverseis an in place reverse, meaning it mutates the array.