12 October 2010

How to Convert a String to Title Case

To convert a string Title Case, simply use the TextInfo class:


using System.Globalization;
using System.Threading;

CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
TextInfo textInfo = cultureInfo.TextInfo;

string result = textInfo.ToTitleCase("this is test");

If the string is in uppercase first convert it to lowercase using the ToLower() method.

No comments: