Are there any built-in functions in .Net that allow to capitalize strings, or handling proper casing? I know there are some somewhere in the Microsoft.VB namespace, but I want to avoid those if possible.
I'm aware of functions like string.ToUpper and string.ToLower() functions however it affects the entire string. I am looking to something like this:
var myString = "micah";
myString = myString.Format(FormattingOptions.Capitalize) //Micah
Just to throw another option into the mix. This will capitalize every word in the given string:
public static string ToTitleCase(string inputString)
{
System.Globalization.CultureInfo cultureInfo =
System.Threading.Thread.CurrentThread.CurrentCulture;
System.Globalization.TextInfo textInfo = cultureInfo.TextInfo;
return textInfo.ToTitleCase(inputString.ToLower());
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With