LINQ – Find all items in one list that aren’t in another list

Try using .Except extension method (docs):

var result = list1.Except(list2);

will give you all items in list1 that are not in list2.

IMPORTANT: Even though there’s a link provided to MSDN docs for the method, I’ll point this out here: Except only works out of the box for collections of primitive types, for POCOs/objects you need to implement IEquatable on that object.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)