DateTime dt = DateTime.Parse("12 January 2009");
dt.ToString("MMM"); // prints "Jan"
// (or the right abbrev is in current culture)
dt.ToString("MMMM"); // prints "January"
// (or correct sp in current culture)
Public Enum MonthsOfYear
January = 1
February = 2
March = 3
April = 4
May = 5
June = 6
July = 7
August = 8
September = 9
October = 10
November = 11
December = 12
End Enum
DateTimeFormatInfo.CurrentInfo.MonthNames (not an enum, but I think that CurrentInfo instance of DateTimeFormatInfo is what you are looking for in general). If you want a drop-down list you could build it like this:
List<string> monthNames = DateTimeFormatInfo.CurrentInfo.MonthNames.Take(12).ToList();
var monthSelectList = monthNames.Select(
m => new { Id = monthNames.IndexOf(m) + 1, Name = m });
I'm looking to see if there is an
数月的官方数字
. net 框架。
没有。
这是我早些时候准备好的。(C # 版本)
public enum Month
{
NotSet = 0,
January = 1,
February = 2,
March = 3,
April = 4,
May = 5,
June = 6,
July = 7,
August = 8,
September = 9,
October = 10,
November = 11,
December = 12
}