c# - Check 3 enum values in one go? -


I have an enum that looks like this:

  enum myEnum {field1 = 11, field 2 = 12, field 3 = 33};  

In my code, I have to say that the field is 1, field 2 is 2 and field 3 is 3 according to a variable i have, i will either variable 1 or 2 or 3; Is this an int? Can I write it in a row? Something like the following, but less ...

  if (myVar == 1) some method (myEnum.field1) ...  

thanks : -)

It seems that the switch statement will be much better than many IPs.

  Switch (Myover) {Case 1: // Break the goods; Case 2: // Break the goods; Case 3: // Content break; }  

Comments