Click here to Skip to main content
13,298,818 members (39,930 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


1 bookmarked
Posted 3 Feb 2011

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

, 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));}
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

You may also be interested in...

Comments and Discussions

GeneralRe: Ah, you are correct. Thanks. Pin
AspDotNetDev5-Feb-11 20:19
protectorAspDotNetDev5-Feb-11 20:19 
GeneralReason for my vote of 3 Short but inefficient. Pin
ChantiPDM21-Feb-11 21:15
memberChantiPDM21-Feb-11 21:15 
GeneralReason for my vote of 4 Thank's Pin
ashishkumar0086-Feb-11 6:21
memberashishkumar0086-Feb-11 6:21 
GeneralI don't see a Reverse function on string. Pin
AspDotNetDev4-Feb-11 8:14
protectorAspDotNetDev4-Feb-11 8:14 
GeneralRe: It's an extension method available (IEnumerable< T >.Reverse... Pin
d@nish 5-Feb-11 13:06
member d@nish 5-Feb-11 13:06 
GeneralReason for my vote of 3 Very nicely condensed, but it is tec... Pin
Kschuler3-Feb-11 10:42
memberKschuler3-Feb-11 10:42 

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

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

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