Programming
C# – Convert Month Number to Month Name
by admin on Jul.30, 2012, under Programming
This is how I get the name of a month as a string when I know the int index of the month only:
string month = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(1);
Another way is to use the ToString() method of the DateTime class. I’m not sure wheter or not this one is culture-specific as well.
string month = DateTime.Parse("January 01, 1900").ToString("MMMM");
or
string month = new DateTime(1900, month, 1).ToString("MMMM");