I have an enum which looks like this:
enum myEnum
{
field1 = 11,
field2 = 12,
field3 = 33
};
In my code I need to say that field1 is 1,field2 is 2 and field3 is 3 according to a variable I have. This variable is either 1 or 2 or 3; it’s an int. Can I write that in one line? Something like the following, but shorter…
if(myVar == 1)
SomeMethod(myEnum.field1)
...
Thanks 🙂
Seems like a switch statement would be better than lots of ifs.