In

public static bool In<T>(this T source,params T[] list)
{
   return list.ToList().Contains(source);
}
Example:
var numbers = new List<int> { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };

//old way using or's
var old = numbers.Where(x=>x==2 || x==3 || x==5||x==7);

//new way using In
var primes = numbers.Where(x => x.In(2, 3, 5, 7));

Description

Filters a list based on a comma-separated list of allowed values. This is a lot more concise than using a number of 'or' clauses

Details

Double click on the code to select all.

 

;