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:

C#-Program-to-Check-Whether-a-String-is-Palindrome-or-Not

C#-Program-to-Check-Whether-a-String-is-Palindrome-or-Not

 

 
We are nothing without our users ! You can help us offer even more high quality content. Please share our page !
Best quality Asp .Net Ajax Control Toolkit tutorials.

Give your valuable comments.

Name
Email
Comment
1 + 8 =
 
About Us | Terms of Use | Privacy Policy | Disclaimer | Contact Us Copyright © 2012-2022 CodingFusion
75 Important SQL Server queries you should know