Click here to Skip to main content
Click here to Skip to main content

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

By , 6 Feb 2011
Rate this:
Please Sign up or sign in to vote.
How about:
public bool IsPalindrome(string stringToCheck)
    char[] rev = stringToCheck.Reverse().ToArray();
    return (stringToCheck.Equals(new string(rev), StringComparison.OrdinalIgnoreCase));


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

About the Author


United States United States
No Biography provided

Comments and Discussions

GeneralRe: Ah, you are correct. Thanks. PinprotectorAspDotNetDev5-Feb-11 19:19 
GeneralReason for my vote of 3 Short but inefficient. PinmemberChantiPDM21-Feb-11 20:15 
GeneralReason for my vote of 4 Thank's Pinmemberashishkumar0086-Feb-11 5:21 
GeneralI don't see a Reverse function on string. PinprotectorAspDotNetDev4-Feb-11 7:14 
GeneralRe: It's an extension method available (IEnumerable< T >.Reverse... Pinmember d@nish 5-Feb-11 12:06 
GeneralReason for my vote of 3 Very nicely condensed, but it is tec... PinmemberKschuler3-Feb-11 9:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140421.2 | Last Updated 7 Feb 2011
Article Copyright 2011 by ZamirF
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid