To check string is Palindrome or not in C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace value
{
class Palindrome
{
static void Main(string[] args)
{
string text, revers="";
Console.WriteLine("Enter the letter ");
text = Console.ReadLine();
// to revese the string value
for( int i = text.Length-1; i>=0; i--)
{
revers+= text[i].ToString();
}
if (text == revers)
{
Console.WriteLine("Letter are same , so is Palindrome {0} {1}", text, revers);
}
else
{
Console.WriteLine("Letter are not same so is not Palindrome {0} {1}", text, revers);
}
Console.ReadLine();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace value
{
class Palindrome
{
static void Main(string[] args)
{
string text, revers="";
Console.WriteLine("Enter the letter ");
text = Console.ReadLine();
// to revese the string value
for( int i = text.Length-1; i>=0; i--)
{
revers+= text[i].ToString();
}
if (text == revers)
{
Console.WriteLine("Letter are same , so is Palindrome {0} {1}", text, revers);
}
else
{
Console.WriteLine("Letter are not same so is not Palindrome {0} {1}", text, revers);
}
Console.ReadLine();
}
}
}
output:-