Using StringBuilder to change string case in C#

string s = "thISisAtestSTringForCaseConversion";
var sb = new StringBuilder(s.Length);
foreach (char c in s)
    sb.Append(char.IsUpper(c) ? char.ToLower(c) : char.ToUpper(c));
s = sb.ToString();

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.