Click or drag to resize

MoreEnumerableExceptByTSource, TKey Method (IEnumerableTSource, IEnumerableTSource, FuncTSource, TKey)

Returns the set of elements in the first sequence which aren't in the second sequence, according to a given key selector.

Namespace:  MoreLinq
Assembly:  MoreLinq (in MoreLinq.dll) Version: 2.4.0
Syntax
public static IEnumerable<TSource> ExceptBy<TSource, TKey>(
	this IEnumerable<TSource> first,
	IEnumerable<TSource> second,
	Func<TSource, TKey> keySelector
)

Parameters

first
Type: System.Collections.GenericIEnumerableTSource
The sequence of potentially included elements.
second
Type: System.Collections.GenericIEnumerableTSource
The sequence of elements whose keys may prevent elements in first from being returned.
keySelector
Type: SystemFuncTSource, TKey
The mapping from source element to key.

Type Parameters

TSource
The type of the elements in the input sequences.
TKey
The type of the key returned by keySelector.

Return Value

Type: IEnumerableTSource
A sequence of elements from first whose key was not also a key for any element in second.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerableTSource. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Remarks
This is a set operation; if multiple elements in first have equal keys, only the first such element is returned. This operator uses deferred execution and streams the results, although a set of keys from second is immediately selected and retained.
See Also