.Net CultureInfo Month Names returning an extra em

2019-04-05 02:39发布

问题:

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:

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

回答1:

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 "".