In this program please explain the reason to have 1, monthNumber and four M. Problem is highlighted.
using System;
class Test
{
static void Main()
{
string s = GetMonth(1);
Console.WriteLine(s);
s = GetMonth(12);
Console.WriteLine(s);
Console.ReadKey();
}
static string GetMonth(int monthNumber)
{
if (monthNumber < 1 || monthNumber > 12)
throw new ArgumentOutOfRangeException();
return new DateTime(1, monthNumber, 1).ToString("MMMM");
}
}
/*
January
December
*/
Turn an integer into a month name
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

VulpesRank #55 · 29.2K reputationPosted Oct 3, 2012, 9:41 AM EDT
new DateTime(1, monthNumber, 1)
The ToString("MMMM") method is then applied to this DateTime to give the full name of the month. "MMMM" is one of .NET's custom date and time formats. See this link for others:
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx
Posted Oct 3, 2012, 10:15 AM EDT