有没有在.NET库pdefined枚举每月$ P $?NET、pdefined

2023-09-02 10:55:10 作者:我爱的少年他如歌

我想看看是否有一个正式的枚举数月在.NET Framework。

I'm looking to see if there is an official enumeration for months in the .net framework.

这似乎有可能,我认为有,因为如何共同利用一个月的是,因为还有其他类似的枚举在.NET Framework之一。

It seems possible to me that there is one, because of how common the use of month is, and because there are other such enumerations in the .net framework.

例如,有一个在一周的枚举的日子里,System.DayOfWeek,其中包括周一,周二,等等。

For instance, there is an enumeration for the days in the week, System.DayOfWeek, which includes Monday, Tuesday, etc..

我在想,如果有一个在年月份,即一月,二月,等等?

I'm wondering if there is one for the months in the year, i.e. January, February, etc?

有谁知道?

推荐答案

没有,但如果你想一个月可以使用的名称:

There isn't, but if you want the name of a month you can use:

CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName (DateTime.Now.Month);

将返回(当前月的,在这种情况下)的字符串重新presentation。需要注意的是的getMonth 需要1参数13 - 1月是1,13是一个空字符串

which will return a string representation (of the current month, in this case). Note that GetMonth takes arguments from 1 to 13 - January is 1, 13 is a blank string.