Try Code Live

Palindrome String

A palindrome string is a string that reads the same forward and backward.

Example:

  • "madam" → if you reverse it, it’s still "madam"
  • "radar" → reversed is "radar"
Not a palindrome
  • "hello" → reversed is "olleh" (not the same).
  • "world" → reversed is "dlrow" (not the same)
In short: A palindrome string is symmetric in reading from left to right and right to left. Write a program to find if string is palindrome string or not

using System;

class Program
{
    static void Main()
    {
        string input = "hello";
        char[] charArray = input.ToCharArray();
        Array.Reverse(charArray);
        string reversed = new string(charArray);
        
        if (input == reversed)
            Console.WriteLine("Palindrome");
        else
            Console.WriteLine("Not Palindrome");
    }
}


Not Palindrome