In C# if I want to see if a variable is equal to one of a set of fixed values, I currently do this…
bool result = ( (x==MyEnum.A) || (x==MyEnum.B) || (x==42) );
…which to me is cumbersome. Is there anything similar to this pseudo-code?
bool result = x in {MyEnum.A, MyEnum.B, 42};
I know I can create an array inline with the values, then use LINQ across that, but are there any other options?
This is probably a BAD idea, but you can turn Contains on its head and get syntax similar to what you ask in your question with a new extension method: