Check if a variable is in an ad-hoc list of values
You could achieve this by using the List.Contains method:
if(new []{1, 2, 3}.Contains(x))
{
//x is either 1 or 2 or 3
}
public static bool In<T>(this T x, params T[] set)
{
return set.Contains(x);
}
...
if (x.In(1, 2, 3))
{ ... }
Required reading: MSDN Extension methods