Say I have an enum type MyEnum. Is there a way in C# to get a list of all possible values for an enum of type MyEnum?
heck you are fast my friend :p.
bastijn
2009-09-02 07:16:09
+5
A:
Enum.GetValues(typeof(SomeEnum));
will return an array with all the values. I do not know if this helps you.
bastijn
2009-09-02 07:15:39
+10
A:
An instance of the enum can have any assignable to the underlying type (i.e., int.MinValue
through int.MaxValue
for any regular enum). You can get a list of the named values by calling Enum.GetNames
and Enum.GetValues
.
280Z28
2009-09-02 07:16:50