How to find out all possible values of an enum?

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?


An instance of the enum can have any assignable to the underlying type (ie, 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 .


Enum.GetValues


Enum.GetValues(typeof(SomeEnum));

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

链接地址: http://www.djcxy.com/p/16286.html

上一篇: 枚举C#和foreach

下一篇: 如何找出枚举的所有可能的值?