Tuesday, April 28, 2009

How to convert a sentence into Title Case (Capitalize first character of every word)?

Use ToTitleCase method.

System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase("dotnetfunda.com is a very good website");

The output will be "Dotnetfunda.Com Is A Very Good Website"
//////////////////////////////////////////////////////////////////////////////////////
Use the namespace System.Globalization

string myString = "syncFusion deVeloPer sUppOrt";
// Creates a TextInfo based on the "en-US" culture.
TextInfo TI = new CultureInfo("en-US",false).TextInfo;
Response.Write (TI.ToTitleCase( myString ));

No comments:

Post a Comment