Introduction
In the below content, you will find simple, different, yet important ways to find whether a string /word is palindrome or not.
Way 1 : Using Array. Reverse () Method
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ProgrammingInterviewFAQ.Palindrome
- {
- class UsingReverseMethod {
- static void Main() {
- Console.WriteLine("Enter the String to check:");
- String input = Console.ReadLine();
- string output = string.Empty;
- char[] inputtochar = input.ToCharArray(); // this line converts the string to char for reversing
- Array.Reverse(inputtochar); // this line actually reverse the Converted CharArray
- output = new string(inputtochar); //this line converts the ReversedcharArray back to string
- if (input == output) {
- Console.WriteLine("Palidrome");
- Console.ReadLine();
- } else {
- Console.WriteLine("Not palindrome");
- Console.ReadLine();
- }
- }
- }
- }using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ProgrammingInterviewFAQ.Palindrome
- {
- class UsingReverseMethod {
- static void Main() {
- Console.WriteLine("Enter the String to check:");
- String input = Console.ReadLine();
- string output = string.Empty;
- char[] inputtochar = input.ToCharArray(); // this line converts the string to char for reversing
- Array.Reverse(inputtochar); // this line actually reverse the Converted CharArray
- output = new string(inputtochar); //this line converts the ReversedcharArray back to string
- if (input == output) {
- Console.WriteLine("Palidrome");
- Console.ReadLine();
- } else {
- Console.WriteLine("Not palindrome");
- Console.ReadLine();
- }
- }
- }
- }

Karthik ElumalaiPosted Aug 23, 2016, 10:05 PM
My Pleasure and happy that it helped you..Thanks for your feedbackRumbidzai Abigail
Rumbidzai MuserepwaPosted Aug 23, 2016, 4:28 PM
Thank you
Karthik ElumalaiPosted Aug 19, 2016, 4:00 AM
Thank youBhuvan Pandey
Bhuvan PandeyPosted Aug 19, 2016, 2:30 AM
Good