using System.Globalization;
string str = "cool strINg";
string str1 = "COOL STRING";
TextInfo objTextInfo = new CultureInfo("en-US",false).TextInfo();
str = objTextInfo.ToTitleCase(str); // Cool String *CORRECT
str1 = objTextInfo.ToTitleCase(str1); // COOL STRING *WRONG
str1 = objTextInfo.ToTitleCase(str1.toLower()); // Cool String *CORRECT
* For FULL CAPITALIZED words, you need to convert them to lower case before passing it to the ToTitleCase() method.
No comments:
Post a Comment