Monday, August 4, 2008

string ToTitleCase

We have a string.ToUpper and string.ToLower, but did you know that we've also got a ToTitleCase? It's not defined in the String class, but rather in the TextInfo class. Here's an example:

string lhello = "hello woRld";
lhello = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(lhello);
Console.WriteLine(lhello); //Hello World

No comments: