Wednesday, May 1, 2013

C# string ToTitleCase. Capitalize the first letters of all words.

Convert string to title case. Capitalize the first letters of all words.


Sample code:
 
//include this
using System.Globalization;

//how to convert from uppercase string to titlecase
string title = "THE TITLE STRING";

TextInfo ti = CultureInfo.CurrentCulture.TextInfo;

title = ti.ToTitleCase(title.ToLower());

//result : "The Title String"
Additional Reading at :
  1. MSDN ToTitleCase

No comments:

Post a Comment