"A string like this", will become, "a STRING LIKE THIS"
"A StRing LIKE this", will become, "a sTrING like THIS"
etc.
public static class StringExtensions
{
public static string InvertCase(this string s)
{
var cArr = s.ToCharArray();
for (var i = 0; i < cArr.Length; i++)
{
var cInt = (int)cArr[i];
if ((cInt >= 65 && cInt <= 90) || (cInt >= 97 && cInt <= 122))
{
cInt ^= 1 << 5;
cArr[i] = (char) cInt;
}
}
return new string(cArr);
}
}