mardi 28 juillet 2015

C# expression equals multiple values

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 ) )

Aucun commentaire:

Enregistrer un commentaire