Steve Steve - 1 year ago 97
C# Question

How to Capitalize names

so basically if i want to transform a name from

stephen smith


Stephen Smith

i can easily do it with come css on the page but ideally I would like to catch it earlier on and change it when it comes out of the database. how can i get csharp to captialize a string.

is there a function for this?

Answer Source

You can do this using the ToTitleCase method of the System.Globalization.TextInfo class:

CultureInfo cultureInfo   = Thread.CurrentThread.CurrentCulture;
TextInfo textInfo = cultureInfo.TextInfo;

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download