C# Program to Check Whether a String is Palindrome or Not
In this C# program, we will take input from the user and Check Whether a String is Palindrome or Not. A String is a palindrome if the reverse of that String is equal to the original
C# Program to Check Whether a String is Palindrome or Not Code:
private static void Main(string[] args)
{
string str, revstr = "";
Console.Write("Enter string: ");
str = Console.ReadLine();
for (int i = str.Length - 1; i >= 0; i--) //String Reverse
{
revstr += str[i].ToString();
}
if (revstr.ToLower() == str.ToLower()) // Checking whether string is palindrome or not
{
Console.Write("Entered string {0} is a Palindrome string. ", str);
}
else
{
Console.Write("Entered string {0} is not a Palindrome string. ", str);
}
Console.ReadLine();
}
C# Program to Check Whether a String is Palindrome or Not Output: