C# program to check whether a given string is a palindrome
Program.cs
Console.WriteLine("———————————————————————————————————————————");Console.WriteLine("Program to check string is palindrome | not");Console.WriteLine("———————————————————————————————————————————");Console.Write("Enter the string ");strings=Console.ReadLine()!;Console.WriteLine("\nLength of a string is "+s.Length);stringr=newstring(s.ToCharArray().Reverse().ToArray()!);Console.WriteLine("\nReverse string is "+r);if(s==r){Console.WriteLine("\nString is palindrome");}else{Console.WriteLine("\nString is not palindrome");}Console.WriteLine("———————————————————————————————————————————");
Output
kodingwindow@kw:~/csharp$ dotnet run
———————————————————————————————————————————
Program to check string is palindrome | not
———————————————————————————————————————————
Enter the string NAAN
Length of a string is 4
Reverse string is NAAN
String is palindrome
———————————————————————————————————————————
kodingwindow@kw:~/csharp$
Dear User, Thank you for visitng KodingWindow. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.