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

How to Toggle String Case in .NET

By , 14 Feb 2011
 
What about this?
 
string s = new string((
            from c in "ABCdef" 
            select char.IsUpper(c) ? char.ToLower(c) : char.ToUpper(c) 
           ).ToArray());
 
Note by Alexander Bell: In regards to the performance, this one (i.e. Alternate 9) is the worst in comparison with Alternate 1 and Alternate 2, also it requires Linq Library, which negatively impacts the Algorithm portability: Alternate 9 is NOT RECOMMENDED

License

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

About the Author

TimB99
Software Developer
New Zealand New Zealand
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralThis one is actually Alternate 8memberDrABELL16 Feb '11 - 6:28 
This one is actually Alternate 8

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

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 14 Feb 2011
Article Copyright 2011 by TimB99
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid