I want to get the month array in c#.
somthing like this : { January , February , ... , December }
How can I do this? please send me codes in C#.
thanks
string[] monthNames = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.MonthNames;
foreach (string m in monthNames) // writing out
{
Console.WriteLine(m);
}
Output:
January
February
March
April
May
June
July
August
September
October
November
December
Update:
Do note that for different locales/cultures, the output might not be in English. Haven't tested that before though.
For US English only:
string[] monthNames = (new System.Globalization.CultureInfo("en-US")).DateTimeFormat.MonthNames;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With