Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C#

To check string is palindrome or not in .NET (C#)

3.50/5 (4 votes)
6 Feb 2011CPOL 12.9K   6  
How about:public bool IsPalindrome(string stringToCheck){ char[] rev = stringToCheck.Reverse().ToArray(); return (stringToCheck.Equals(new string(rev), StringComparison.OrdinalIgnoreCase));}
How about:

C#
public bool IsPalindrome(string stringToCheck)
{
    char[] rev = stringToCheck.Reverse().ToArray();
    return (stringToCheck.Equals(new string(rev), StringComparison.OrdinalIgnoreCase));
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)