Skip to content

How to Toggle String Case in .NET

Well, this one comes from after a discussion from one of threads on CodeProject. The following snippet shows how to toggle string casing in .NET:

public string ToggleCase(string input)
    string result = string.Empty;
    char[] inputArray = input.ToCharArray();
    foreach (char c in inputArray)
        if (char.IsLower(c))
            result += Char.ToUpper(c);
            result += Char.ToLower(c);
    return result;
Published inUncategorized

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *