public class Test
{
int i;
string s;
}
List<Test> testList = new List<Test>(); //assume there are some values in it.
List<int> intList = new List<int>(){ 1,2,3};
How to I say get items from testList where i is in intList using the linq to objects.
something like List<Test> testIntList = testList.Where(t=>t.i in intList)
Technically, it would be:
However, that might be slow if
intListis large, sinceList<T>.Containsperforms its search in O(n). A faster approach would be to use aHashSet<T>: