Click here to Skip to main content
15,885,914 members
Articles / Programming Languages / C#
Alternative
Tip/Trick

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

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
15 Feb 2011CPOL 5.2K   1   1  
How about this:private bool IsPalindrome(string stringToCheck){ return stringToCheck.ToLower() == (new string(stringToCheck.Reverse().ToArray())).ToLower();}
How about this:
C#
private bool IsPalindrome(string stringToCheck)
{
    return stringToCheck.ToLower()
               == (new string(stringToCheck.Reverse().ToArray())).ToLower();
}

License

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


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --