Home
Manage Your Code
Snippet: Format a String in TitleCase (C#)
Title: Format a String in TitleCase Language: C#
Description: How to format a string in TitleCase: for example "hello my friend" -> "Hello My Friend" Views: 4462
Author: Genesio Lini Date Added: 5/8/2009
Copy Code  
1using System.Globalization;
2
3String myString = "HI, I AM GENESIO";
4
5String myTitleCaseString = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(myString.ToLower());
Notes
always remember to use LowerCase() before passing the string to ToTitleCase beacuse it only transforms lowercase characters in uppercase and not vice-versa