Possible Duplicate:
How do I enumerate an enum?
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?
CA1069: Enums should not have duplicate values.
Enums don't have methods for iteration, like forEach() or iterator(). Instead, we can use the array of the Enum values returned by the values() method.
Two enum names can have same value. For example, in the following C program both 'Failed' and 'Freezed' have same value 0.
Enum.GetValues
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
.
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