check for palindrome in C# code example
Example: c# palidrone
public static void Main(string[] args)
{
Console.WriteLine(new Program().Pal("AsdsA"));
}
public bool Pal(string str)
{
int end = str.Length-1;
for (int i = 0, j = end; i < end; i++, j--)
{
char frontLetter = str[i];
char endLetter = str[j];
if (frontLetter != endLetter) return false;
}
return true;
}
---------------------------------------------------------Option1
public bool Pal(string str)
{
char[] rev = str.ToCharArray();
Array.Reverse(rev);
string reversed = new string(rev);
if (str.Equals(reversed)) return true;
else return false;
}
----------------------------------------------------------Option2