Click here to Skip to main content
11,572,401 members (50,423 online)
Click here to Skip to main content

Tagged as

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

, 6 Feb 2011 CPOL 3.4K 6 1
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));
}

License

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

Share

About the Author

ZamirF
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 19:19
protectorAspDotNetDev5-Feb-11 19:19 
GeneralReason for my vote of 3 Short but inefficient. Pin
ChantiPDM21-Feb-11 20:15
memberChantiPDM21-Feb-11 20:15 
GeneralReason for my vote of 4 Thank's Pin
ashishkumar0086-Feb-11 5:21
memberashishkumar0086-Feb-11 5:21 
GeneralI don't see a Reverse function on string. Pin
AspDotNetDev4-Feb-11 7:14
protectorAspDotNetDev4-Feb-11 7:14 
I don't see a Reverse function on string.
GeneralRe: It's an extension method available (IEnumerable< T >.Reverse... Pin
d@nish 5-Feb-11 12:06
member d@nish 5-Feb-11 12:06 
GeneralReason for my vote of 3 Very nicely condensed, but it is tec... Pin
Kschuler3-Feb-11 9:42
memberKschuler3-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 | Terms of Use | Mobile
Web04 | 2.8.150624.2 | Last Updated 7 Feb 2011
Article Copyright 2011 by ZamirF
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid