Enumerable.IntersectBy Method (System.Linq) (original) (raw)
Source:
Source:
Source:
Produces the set intersection of two sequences according to a specified key selector function.
public:
generic <typename TSource, typename TKey>
[System::Runtime::CompilerServices::Extension]
static System::Collections::Generic::IEnumerable<TSource> ^ IntersectBy(System::Collections::Generic::IEnumerable<TSource> ^ first, System::Collections::Generic::IEnumerable<TKey> ^ second, Func<TSource, TKey> ^ keySelector, System::Collections::Generic::IEqualityComparer<TKey> ^ comparer);
public static System.Collections.Generic.IEnumerable<TSource> IntersectBy<TSource,TKey>(this System.Collections.Generic.IEnumerable<TSource> first, System.Collections.Generic.IEnumerable<TKey> second, Func<TSource,TKey> keySelector, System.Collections.Generic.IEqualityComparer<TKey>? comparer);
static member IntersectBy : seq<'Source> * seq<'Key> * Func<'Source, 'Key> * System.Collections.Generic.IEqualityComparer<'Key> -> seq<'Source>
<Extension()>
Public Function IntersectBy(Of TSource, TKey) (first As IEnumerable(Of TSource), second As IEnumerable(Of TKey), keySelector As Func(Of TSource, TKey), comparer As IEqualityComparer(Of TKey)) As IEnumerable(Of TSource)
Type Parameters
TSource
The type of the elements of the input sequences.
TKey
The type of key to identify elements by.
Parameters
keySelector
Func<TSource,TKey>
A function to extract the key for each element.
Returns
A sequence that contains the elements that form the set intersection of two sequences.
Exceptions
Remarks
This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its GetEnumerator
method directly or by using foreach
in C# or For Each
in Visual Basic.
The intersection of two sets A and B is defined as the set that contains all the elements of A that also appear in B, but no other elements.
When the object returned by this method is enumerated, Intersect
yields distinct elements occurring in both sequences in the order in which they appear in first
.
If comparer
is null
, the default equality comparer, Default, is used to compare values.