Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

How to get an array of months in c#

var months = new string[12]; 
for (var month = 1; month <= 12; month++)
{
	var firstDay = new DateTime(DateTime.Now.Year, month, 1);
  	var name = firstDay.ToString("MMMM", CultureInfo.CreateSpecificCulture("en"));
  	months[month - 1] = name;
}

foreach (var month in months) 
{
	Console.WriteLine($"-> {month}");
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #How #array #months
ADD COMMENT
Topic
Name
5+8 =