I am comparing a variable to many enum values, but the IntelliSense is giving me this warning:
if (val == MyEnum.Value1 | MyEnum.Value2 | MyEnum.Value3){
//code
}
My enum looks like this:
public enum MyEnum
{
[Description("Value1")]
Value1 = 0,
[Description("Value2")]
Value2 = 1,
[Description("Value3")]
Value3 = 2,
}
What is it and what should I do? Is it safe? All i want to avoid is having to write the long version of an if multi-value comparison block.