I was about to write my own C# extension to convert a string to Proper Case (i.e. capitalize the first letter of every word), then I wondered if there's not a native C# function to do just that... is there?
The ToTitleCase method is used to capitalize the first letter in a word. Title case itself means to capitalize the first letter of each major word.
Convert all the elements in each and every word in to lowercase using string. toLowerCase() method. Loop through first elements of all the words using for loop and convert them in to uppercase.
String s = "yOu caN Use thIs" s = System.Threading.Thread.CurrentThread .CurrentCulture.TextInfo.ToTitleCase(s.ToLower());
The main limitation I can see with this is that it's not "true" title case. i.e. In the phrase "WaR aNd peaCe", the "and" part should be lowercase in English. This method would capitalise it though.
There is a function that capitalises the first letters of words, though you should see the remarks section as it does have some limitations which may make it unsuitable for your needs.
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