我有一个枚举声明为
enum class AccessLevel : int
{
ReadOnly = 0,
Excluded = 1,
ReadWrite = 2,
};
和一个声明为
的数组static array<String^>^ _accessMap = gcnew array<String^> { "R", "X", "W" };
我想做这样的事情:
AccessLevel^ access = access::ReadOnly;
String^ foo = _accessMap[access];
答案 0 :(得分:2)
public enum struct AccessLevel
{
ReadOnly = 0,
Excluded = 1,
ReadWrite = 2,
};
AccessLevel access = access::ReadOnly;
您可能需要转换为int
String^ foo = _accessMap[(int)access];