Returns the set of elements in the first sequence which aren't
in the second sequence, according to a given key selector.
Declaration Syntax
C# | Visual Basic | Visual C++ |
public static IEnumerable<TSource> ExceptBy<TSource, TKey>( this IEnumerable<TSource> first, IEnumerable<TSource> second, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> keyComparer )
<ExtensionAttribute> _ Public Shared Function ExceptBy(Of TSource, TKey) ( _ first As IEnumerable(Of TSource), _ second As IEnumerable(Of TSource), _ keySelector As Func(Of TSource, TKey), _ keyComparer As IEqualityComparer(Of TKey) _ ) As IEnumerable(Of TSource)
public: [ExtensionAttribute] generic<typename TSource, typename TKey> static IEnumerable<TSource>^ ExceptBy( IEnumerable<TSource>^ first, IEnumerable<TSource>^ second, Func<TSource, TKey>^ keySelector, IEqualityComparer<TKey>^ keyComparer )
Generic Template Parameters
- TSource
- The type of the elements in the input sequences.
- TKey
- The type of the key returned by keySelector.
Parameters
- first (IEnumerable<(Of <(<'TSource>)>)>)
- The sequence of potentially included elements.
- second (IEnumerable<(Of <(<'TSource>)>)>)
- The sequence of elements whose keys may prevent elements in first from being returned.
- keySelector (Func<(Of <(<'TSource, TKey>)>)>)
- The mapping from source element to key.
- keyComparer (IEqualityComparer<(Of <(<'TKey>)>)>)
- The equality comparer to use to determine whether or not keys are equal. If null, the default equality comparer for TSource is used.
Return Value
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 IEnumerable<(Of <(<'TSource>)>)>. When you use instance method syntax to call this method, omit the first parameter.
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.
Assembly: MoreLinq (Module: MoreLinq.dll) Version: 1.0.16006.0 (1.0.16006.1845)