c# First monthletter in uppercase
I'd suggest to clone a culture and re-define a new month names in it:
var swedish = CultureInfo.GetCultureInfo("sv-SE");
swedish = (CultureInfo)swedish.Clone();
swedish.DateTimeFormat.MonthNames =
swedish.DateTimeFormat.MonthNames
.Select(m => swedish.TextInfo.ToTitleCase(m))
.ToArray();
swedish.DateTimeFormat.MonthGenitiveNames =
swedish.DateTimeFormat.MonthGenitiveNames
.Select(m => swedish.TextInfo.ToTitleCase(m))
.ToArray();
and then use it in string.Format
method:
// date holds "Mars"
var date = String.Format(swedish, "{0:MMMM}", DateTime.Now);
To make months in upper case I use TextInfo.ToTitleCase
method.
There are some good answers here already. If you want a function you can write:
char.ToUpper(s[0]) + s.Substring(1);