13

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?

1

3 Answers 3

15

Enum.GetValues

Sign up to request clarification or add additional context in comments.

Comments

11

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.

Comments

7

Enum.GetValues(typeof(SomeEnum));

will return an array with all the values. I do not know if this helps you.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.