I’m trying to pass around an unknown enum type which is set by switch cases then automatically generate arrays from them. Given that the following, which I use in other areas of code, works:
subType = new EquipmentSubTypeList[Enum.GetNames(typeof(EQUIPMENTTYPE)).Length];
I tried the following which doesn’t:
Type enumType;
switch (equipmentType)
{
case EQUIPMENTTYPE.Weapon:
enumType = typeof(WEAPONTYPE);
break;
}
if (subType == null || subType.Length < 1)
{
subType = new EquipmentSubTypeList[Enum.GetNames(enumType).Length];
}
GetNames(enumType) is where I am getting the error in VS. I can’t figure out why this isn’t working. Any help with why it doesn’t and any advice for achieving what I am trying to would be greatly appreciated.