This program tells us whether the given string is a palindrome or not. But before we proceed further, it is very important to know what a palindrome is. A palindrome is a word, number, or sequence of characters which is the same whether we read it forward or from backward.
Example
mom, madam, racecar, 1001, and many more.
Now, let us move to the C# coding part. The code is simple so there is no need to explain it.
  1. class Program
  2. {
  3. static void Main(string[] args)
  4. {
  5. Console.WriteLine("Enter the String");
  6. Console.WriteLine("------------------");
  7. string GetText = Console.ReadLine();
  8. Program p = new Program();
  9. p.Palindrome(GetText);
  10. Console.ReadLine();
  11. }
  12. public void Palindrome(string str)
  13. {
  14. string rev = "";
  15. for(int i=str.Length-1;i>=0;i--)
  16. {
  17. rev += str[i].ToString();
  18. }
  19. Console.WriteLine("Reversed String:");
  20. Console.WriteLine("-----------------");
  21. Console.WriteLine(rev);
  22. Console.WriteLine("-----------------");
  23. if(rev==str)
  24. {
  25. Console.WriteLine("The given string {0} is Palindrome",str);
  26. }
  27. else
  28. {
  29. Console.WriteLine("The given string {0} is not Palindrome",str);
  30. }
  31. }
  32. }
Hope you find this helpful