To convert string to title case (capitalize initial letters of the string), there is not string method to call. However, we can use the CultureInfo from Globalization and use the TextInfo’s ToTitleCase method.
Here is how it can be done in C#:
Add class StringExtensions to your root namespace and copy the code,All string variables in your project will now shows ToTitleCase method (extension method)
public static class StringExtensions { public static string ToTitleCase(this string input) { System.Globalization.CultureInfo cultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture; System.Globalization.TextInfo textInfo = cultureInfo.TextInfo; return textInfo.ToTitleCase(input.ToLower()); } }