How to Capitalize Every First Letter of a String using .NET

Waqas Anwar
07 November 2010
10971 Views

You have a string and you want to capitalize every first letter of every word of that string just like Title case feature of Microsoft Word. You can use ToTitleCase method as shown in the code snippet below.

Import System.Globalization namespace on top of your file to use CultureInfo class.string normalString = "The quick brown fox jumps over the lazy dog.";
 
string titleCaseString =
   CultureInfo.CurrentCulture.TextInfo.ToTitleCase(normalString);

The output will be:

The Quick Brown Fox Jumps Over The Lazy Dog.