列挙型
構文
アンマネージド
enum MyEnum { A, B, C };
int e1 = B;
int e2 = MyEnum::B;
マネージド
access enum class name [:type] { enumerator-list } var;
Syntax - enum class (C++ Component Extensions) | MSDN
enum class MyEnum { D, E, F };
int e1 = E;
int e2 = MyEnum::E;
MyEnum e3 = E;
MyEnum e4 = MyEnum::E;
型の変換
enum UnmanagedEnum { A, B, C };
enum class ManagedEnum { D, E, F };
int u1 = A;
int u2 = B;
int m1 = (int)ManagedEnum::D;
int m2 = (int)ManagedEnum::E;
UnmanagedEnum un1 = (UnmanagedEnum)0;
UnmanagedEnum un2 = (UnmanagedEnum)1;
ManagedEnum ma1 = (ManagedEnum)0;
ManagedEnum ma2 = (ManagedEnum)1;