A palindrome string is the one that once reversed produces the same result as the original input string. Let us proceed with an example for the same.
Write the following code in a console application.
- static void Main(string[] args)
- {
- string _inputstr, _reversestr = string.Empty;
- Console.Write("Enter a string : ");
- _inputstr = Console.ReadLine();
- if (_inputstr != null)
- {
- for (int i = _inputstr.Length - 1; i >= 0; i--)
- {
- _reversestr += _inputstr[i].ToString();
- }
- if (_reversestr == _inputstr)
- {
- Console.WriteLine("String is Palindrome Input = {0} and Output= {1}", _inputstr, _reversestr);
- }
- else
- {
- Console.WriteLine("String is not Palindrome Input = {0} and Output= {1}", _inputstr, _reversestr);
- }
- }
- Console.ReadLine();
- }
Output


SubashPosted Jul 14, 2016, 3:44 AM
Nice