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

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.



About author

User avatar

Waqas Anwar

Founder of, Senior Consultant, Microsoft .NET and Web Technologies