Proper casing of the strings
Many a times we are required to show strings with proper casings. The TextInfo property from System.Globalization provides culture-specific casing information for strings. This has the advantage that it is culture aware and thus can be used for any country specific culture. This is how you would use it.
Two specific namespaces required for this:
using System.Globalization; using System.Threading; protected void Page_Load(object sender, EventArgs e) { string myTitle = "to Proper casing"; CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; TextInfo textInfo = cultureInfo.TextInfo; Console.WriteLine(textInfo.ToTitleCase(myTitle)); Console.WriteLine(textInfo.ToLower(myTitle)); Console.WriteLine(textInfo.ToUpper(myTitle)); }
//Result: To Proper Casing
//Result: to proper casing
//Result: TO PROPER CASING