i have an enum declared as
我有一个enum声明为
enum class AccessLevel : int
{
ReadOnly = 0,
Excluded = 1,
ReadWrite = 2,
};
and an Array declared as
和一个声明为的数组
static array<String^>^ _accessMap = gcnew array<String^> { "R", "X", "W" };
I want to do something like this:
我想做这样的事情:
AccessLevel^ access = access::ReadOnly;
String^ foo = _accessMap[access];
1 个解决方案
#1
public enum struct AccessLevel
{
ReadOnly = 0,
Excluded = 1,
ReadWrite = 2,
};
AccessLevel access = access::ReadOnly;
you might need to cast to an int
你可能需要转换为int
String^ foo = _accessMap[(int)access];
#1
public enum struct AccessLevel
{
ReadOnly = 0,
Excluded = 1,
ReadWrite = 2,
};
AccessLevel access = access::ReadOnly;
you might need to cast to an int
你可能需要转换为int
String^ foo = _accessMap[(int)access];