How to check Palindrum string

Rajesh_Kumar
Posted by Rajesh_Kumar under C# category on | Points: 40 | Views : 737
static void Main(string[] args)
{
string str, revstr;
Console.WriteLine("Enter Any String to Know It is Palindrome or not");
str = Console.ReadLine();
char[] tempstr = str.ToCharArray();
Array.Reverse(tempstr);
revstr = new string(tempstr);
bool caseignore = str.Equals(revstr, StringComparison.OrdinalIgnoreCase);
if (caseignore == true)
{
Console.WriteLine("............" + str + " Is a Palindrome..........");
}
else
{
Console.WriteLine("............" + str + " Is Not a Palindrome........");
}
Console.Read();
}

Comments or Responses

Login to post response