I can use Except() on two same types like:
var list1 = new List<int> { 1 , 2 , 3 , 5 , 9 };
var list2 = new List<int> { 4 , 3 , 9 };
var expectedList = list1.Except(list2);//Result: { 1 , 2 , 5 }
But how to do with different types? like:
var cats = new List<Cat>();
var dogs = new List<Dog>();
var exceptCats = cats
.Except(dogs)
.On(cat.Age == dog.Age && cat.Name == dogs.Name)
Using
Except()for excluding the first set with the second set which both are the same type.You can use
.Where()to filter in this case which has the same behavior.