var third = first.Except(second);
(you can also call ToList()
after Except()
, if you don't like referencing lazy collections.)
The Except()
method compares the values using the default comparer, if the values being compared are of base data types, such as int
, string
, decimal
etc.
Otherwise the comparison will be made by object address, which is probably not what you want... In that case, make your custom objects implement IComparable
(or implement a custom IEqualityComparer
and pass it to the Except()
method).