Is there another way to write something like this:
if (a == x || a == y || a == z)
One way that I found is doing it like this:
So, you want to replace a simple, efficent language construct that contains short-circuit optimisations into something much slower that has the potential for throwing exceptions?
However, if the items you want to compare against are not fixed in quantity, i.e. at run time it could be t,u,v,w,x,y,z,etc..., then the Collection.Contains method is the only option, but then you'd be passing collection objects around rather than individual values and so there's little memory allocation ovrehead.
If you've got a large number of items to compare 'a' against, but the items are not dynamic at run time then a switch statement might be a better fit.