My sharing and discussion of topics in C#, WCF, WPF, Winforms, SQL, ASP.Net, Windows Service, Java Script .... with you all.
Tuesday, July 16, 2013
Palindrome Checking in C#
Here is a short code to do this:
private string CheckPalinDrome(string text)
{
//Converting into Upper case and remove blank spaces in between
text = textBox2.Text.ToUpper().Replace(" ", string.Empty);
string revText = ReverseString(text);
if (revText == text)
{
return("palindrome");
}
else
{
return ("Not palindrome");
}
}
private string ReverseString(string s)
{
char[] arr = s.ToCharArray();
Array.Reverse(arr);
return new string(arr);
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment