How to Convert String to Title Case – ASP .NET
Often times you might need to convert input string to title case.
For example converting the string “mY GiaNT bREAkFST” to “My Giant Breakfast”
Using this simple method you could convert an input string to title case
public class Converter
{
public static string ConvertToTitleCase(string input)
{
TextInfo ti = Thread.CurrentThread.CurrentCulture.TextInfo;
//if a word is all in upper case, ToTitleCase method is not able to convert to title case. So we would make the input string all lower case.
return ti.ToTitleCase(input.ToLower());
}
}
To use this method you can simply call the static method like this:
string str = Converter.ConvertToTitleCase(“mY GiaNT bREAkFST”)
From Webcosmo Webmaster Forum http://www.webcosmoforums.com/asp/21519-how-convert-string-title-case-asp-net.html










Leave your response!