I'm sure the answer is going to be no but I was curious and thought I'd ask you boffins just to be sure.
In SQL you can say:
IF ( a IN ( x, y ) )
Is there something similar in C#? I know you can use a switch but I'm looking for something specifically possible in an if statement due to having multiple expressions like:
IF ( a == b && c IN ( x, y ) )
IF ( a == b && c == ( x || y ) )
Edit: Ok, I see I oversimplified as the array example is rather obvious and I didn't think it through. How about if it's something more complex like:
if ( a.GetType() == typeof( MyClass1 ) || a.GetType() == typeof( MyClass2 ) )
Edit2: Just to clarify, this is not a duplicate of Is there a C# IN operator? as the answers to that question don't address my question as the example I used was maybe a little poor but it was the only relation I could think of at the time. The answer provided by Palani Kumar is the answer I was looking for.
Edit3: Thanks to everyone for weighing in. It's quite clear that there are numerous ways to achieve the same result (I also understand now that they're pretty much the same thing which is just being expressed differently) and I have been able to read further into each one thanks to your input. I also managed to find this "if statements matching multiple values" post which yes, I fully agree that it too is a duplicate of what I asked. Based on the feedback I've not only learnt a lot but managed to also implement an elegant solution being:
public static bool In<T>( this T obj, params T[] list )
{
return list.Contains( obj );
}