Is there a better way than this to convert a string to MixedCase?

So i wanted to convert a string to mixed case and i couldn’t think of anything better than this, my question is, is there a better/more optimal way of doing this ?

string text = "something like this"; string textmixedcase = ""; int i = 0; foreach (char ch in text) { i++; if (i % 2 == 0) { textmixedcase += ch.ToString().ToUpper(); } else { textmixedcase += ch.ToString().ToLower(); } 

Example output: sOmeThInG lIkE tHiS

submitted by /u/_Luciifer
[link] [comments]

Leave a Reply