Pages

Tuesday, 21 January 2014

Display Month short/full name

static string GetMonthName(int monthNum, bool abbreviate)
{
if (monthNum < 1 || monthNum > 12)
throw new ArgumentOutOfRangeException(“monthNum”);
DateTime date = new DateTime(1, monthNum, 1);
if (abbreviate)
return date.ToString(“MMM”);
else
return date.ToString(“MMMM”);
}

No comments:

Post a Comment