I have lines like this:
var a = "abc"; var b = "DEF"; var c = "gHi";
Is there a function that I can apply to a string to change it so that the first character is in uppercase and then lowercase?
You could write your own quite easily.
public string Capitalise(string str) { if (String.IsNullOrEmpty(str)) return String.Empty; return Char.ToUpper(str[0]) + str.Substring(1).ToLower(); }
ToTitleCase() is the perfect solution. You can find the link to create an extension method below. Or for fun, you can create it yourself ...
ToTitleCase()
public string ToProperCase(string str) { if (string.IsNullOrEmpty(str)) return str; return str[0].ToUpper() + str.Substring(1).ToLower(); } // or an extension method public static string ToProperCase(this string str) { if (string.IsNullOrEmpty(str)) return str; return str[0].ToUpper() + str.Substring(1).ToLower(); }
Link to create ToTitleCase() as an extension method on System.String:
http://geekswithblogs.net/mucman/archive/2007/03/26/109892.aspx
Using
CultureInfo.CurrentCulture.TextInfo.ToTitleCase( yourstring);
You can use the Title Case ... http://support.microsoft.com/kb/312890/EN-US/
Source: https://habr.com/ru/post/1386642/More articles:How to access previous Entity state? - javaPrevent Windows control keys in jQuery - jqueryDirection of Shells / Bullet Cocos2d - iosMonsters / Enemies on platforms (like Doodlejump) Cocos2d - iosquick enumeration of an NSDictionary instance ordered by key - objective-cFocusing in the right window - winapiWhat is the difference between Fluent Mapping and Auto mapping in Fluent NHibernate - fluent-nhibernateInitializing Objective-C of class ivar, which is an array of C - cWhat is best for performance: XPathNavigator with XPath vs Linq in Xml with query? - c #Finding memory usage of a single class in C ++ - c ++All Articles