Except method

Enumerable<T> Except (Iterable<T> other, { EqualityComparer<T> comparer })

Returns the set difference between the enumerable and the given collection.

After applying the Except method to an enumerable, the resulting enumerable will consist of all the elements in the source enumerable that are not present in the given other collection. This is equivalent to taking the set difference of the two sequences.

Optionally, an EqualityComparer can be supplied to handle comparisons. If one is provided, the Except method will use the comparer and hasher properties in order to determine equivalency. If omitted, Except will resort to strict equivalency (i.e. checking if (value == element)).

(For the Except method, only the comparer and hasher properties of the EqualityComparer need be supplied.)

If none of the elements in the source enumerable match any element in the given other collection, the enumerable will be unchanged.

Implementation

Enumerable<T> Except(Iterable<T> other, {EqualityComparer<T> comparer}) {
  return ExceptEnumerable<T>(this, other, comparer);
}