There is no direct string function to convert a given case string to a Mixed Case or Title Case (first letter of the word is capitalized)

Below is the code you can achieve this using the CultureInfo in Globalization namespace:

string myString = "test string";

System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;
System.Globalization.TextInfo textInfo = cultureInfo.TextInfo;

string mixedCaseString = textInfo.ToTitleCase(myString.ToLower());

The mixedCaseString will be "Test String".


  1. Sahara // November 11, 2008 at 8:36 PM  

    Well written article.

  2. ChrisWoodruff // February 23, 2009 at 9:58 AM  

    Thanks - your article was just what I needed, consise and to the point.

    One additional item I wish to point out, you may want to change myString to myString.ToLower() when you pass it to "ToTitleCase".

    I have found the it will not DROP the case of letters... for instance..
    "MY STRING" will remain as "MY STRING" - the function appears to only "look at" the first character of each word.

    Thanks again!

  3. Moderator // February 23, 2009 at 10:41 AM  

    Thanks for the catch Chris. I have updated the code.