我有以下代码:
// Obtain the string names of all the elements within myEnum
String[] names = Enum.GetNames( typeof( myEnum ) );
// Obtain the values of all the elements within myEnum
Array values = Enum.GetValues( typeof( myEnum ) );
// Print the names and values to file
for ( int i = 0; i < names.Length; i++ )
{
print( names[i], values[i] );
}
Run Code Online (Sandbox Code Playgroud)
但是,我无法索引值.有更简单的方法吗?
或者我完全错过了什么!
可能重复:
循环枚举值
假设我们正在处理一副牌
typedef enum {
HEARTS, CLUBS, DIAMONDS, SPADES, SUIT_NOT_DEFINED
} Suit;
Run Code Online (Sandbox Code Playgroud)
我如何枚举枚举?