.Net CultureInfo Month Names returning an extra empty string
Asked Answered
C

1

15

I have the following code to get a list of Month names:

var monthNames = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.MonthNames;

For some reason, this keeps returning an additional empty string value along with the Month names:

enter image description here

I am using Xamarin Studio. Anyone else encounter this before?

Claudetteclaudia answered 4/12, 2015 at 1:18 Comment(0)
C
21

Some calendars like TaiwanLunisolarCalendar or KoreanLunisolarCalendar have 13 months.

In a 12-month calendar, the 13th element of the array is an empty string.

DateTimeFormatInfo.MonthNames
A one-dimensional array of type String containing the culture-specific full names of the months. In a 12-month calendar, the 13th element of the array is an empty string. The array for InvariantInfo contains "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", and "".

Continent answered 4/12, 2015 at 1:22 Comment(3)
Ah! I should have done more research before posting. Thanks for the quick response!Claudetteclaudia
I was curious why that decision was made; turns out there are lunisolar calendars which do infact have 13 months. Taiwan - Korea, etcIsolated
@Isolated Thank you for mentioning that calendars, I added them to the answer as examples of calendars with 13 monthes.Continent

© 2022 - 2024 — McMap. All rights reserved.