Interesting finding in regards to the Case Toggle Algorithm by Robert (see the following code snippet):
protected string ToggleCaseByRobert(string s)
{
var sb = new StringBuilder(s.Length);
foreach (char c in s)
sb.Append(char.IsUpper(c) ? char.ToLower(c) : char.ToUpper(c));
return sb.ToString();
}
The functionality will stay the same if the line:
var sb = new StringBuilder(s.Length);
is replaced with simplified version:
var sb = new StringBuilder();
but the original version demonstrates about 5...10% performance boost. Kudos to Robert Rohde for this useful tip!