Sunday, February 24, 2008

How to convert a string to proper case

To convert a string to proper case we will have to use the System.Globalization namespace.

To do this we will use the following code.

string myString = "VikRAM’s WebSite HaVinG a post oN pRoper cAsE";

TextInfo TI = new CultureInfo("en-US",false).TextInfo;

Response.Write (TI.ToTitleCase( myString ));

[Note: Generally, title casing converts the first character of a word to uppercase and converts the rest of the letters to lowercase.]

No comments: