I have three different Enum and all of three has same identifier but different values. I want to access particular enum based on some condition.
for example:
Public Enum Type1
Font = 10
Color = 11
End Enum
Public Enum Type2
Font = 20
Color = 21
End Enum
Public Enum Type3
Font = 30
Color = 31
End Enum
And based on certain condition i need to access particular enum. for example,
if(somecondition = 1)
return Type1.Font
else if (somecondition = 2)
return Type2.Font
else if (somecondition = 3)
return Type3.Font
I need to repeat same logic to access other enum identifier. Is there any way I can write generic method that return me enum value?
for example,
public function GetEnumValue(enumtype, identifier) as integer
return enumtype.identifier
end function
Is there any way to write above generic function to return enum value?
Updated: I am looking for method like GetEnumValue(Type1,Font) that returns enum value in integer (in this case 10 for type1.font)
Your question is extremely unclear.
You may be looking for
Where
enumTypeis aTypeobject andvalueNameis a string.