问题
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 forInvariantInfo
contains"January"
,"February"
,"March"
,"April"
,"May"
,"June"
,"July"
,"August"
,"September"
,"October"
,"November"
,"December"
, and""
.
来源:https://stackoverflow.com/questions/34079337/net-cultureinfo-month-names-returning-an-extra-empty-string