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

 

 
About Us | Terms of Use | Privacy Policy | Disclaimer | Contact Us Copyright © 2012-2024 CodingFusion
50+ C# Programs for beginners to practice