I'm looking to see if there is an official enumeration for months in the .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.
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?
Does anyone know?
An enumeration is a set of named integer constants. An enumerated type is declared using the enum keyword. C# enumerations are value data type. In other words, enumeration contains its own values and cannot inherit or cannot pass inheritance.
An enumeration type (or enum type) is a value type defined by a set of named constants of the underlying integral numeric type. To define an enumeration type, use the enum keyword and specify the names of enum members: C# Copy. enum Season { Spring, Summer, Autumn, Winter }
There isn't, but if you want the name of a month you can use:
CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName (DateTime.Now.Month);
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.
No, there isn't.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With