Enumerable.IntersectBy 方法

定義

多載

IntersectBy<TSource,TKey>(IEnumerable<TSource>, IEnumerable<TKey>, Func<TSource,TKey>, IEqualityComparer<TKey>)

根據指定的索引鍵選取器函式,產生兩個序列的集合交集。

IntersectBy<TSource,TKey>(IEnumerable<TSource>, IEnumerable<TKey>, Func<TSource,TKey>)

根據指定的索引鍵選取器函式,產生兩個序列的集合交集。

IntersectBy<TSource,TKey>(IEnumerable<TSource>, IEnumerable<TKey>, Func<TSource,TKey>, IEqualityComparer<TKey>)

來源:
Intersect.cs
來源:
Intersect.cs
來源:
Intersect.cs

根據指定的索引鍵選取器函式,產生兩個序列的集合交集。

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)

類型參數

TSource

輸入序列之項目的類型。

TKey

要識別專案的索引鍵類型。

參數

first
IEnumerable<TSource>

傳回其獨特項目同時出現在 second 中的 IEnumerable<T>

second
IEnumerable<TKey>

傳回其獨特項目同時出現在第一個序列中的 IEnumerable<T>

keySelector
Func<TSource,TKey>

用來擷取各項目之索引鍵的函式。

comparer
IEqualityComparer<TKey>

用來比較金鑰的 IEqualityComparer<T>

傳回

IEnumerable<TSource>

序列,其中包含形成兩個序列之交集的項目。

例外狀況

firstsecondnull

備註

這個方法是使用延後執行來實作。 立即傳回值是一個物件,會儲存執行動作所需的所有資訊。 除非直接呼叫其 GetEnumerator 方法或在 C# 或 foreachFor Each Visual Basic 中使用 來列舉物件,否則不會執行這個方法所代表的查詢。

兩組 A 和 B 的交集定義為集合,其中包含同時出現在 B 中的所有 A 元素,但沒有其他元素。

列舉這個方法所傳回的物件時, Intersect 會以出現在 中的順序產生兩個序列中 first 發生的相異專案。

如果 為 comparernull ,則會使用預設相等比較子 Default 來比較值。

另請參閱

適用於

IntersectBy<TSource,TKey>(IEnumerable<TSource>, IEnumerable<TKey>, Func<TSource,TKey>)

來源:
Intersect.cs
來源:
Intersect.cs
來源:
Intersect.cs

根據指定的索引鍵選取器函式,產生兩個序列的集合交集。

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);
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);
static member IntersectBy : seq<'Source> * seq<'Key> * Func<'Source, '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)) As IEnumerable(Of TSource)

類型參數

TSource

輸入序列之項目的類型。

TKey

要識別專案的索引鍵類型。

參數

first
IEnumerable<TSource>

傳回其獨特項目同時出現在 second 中的 IEnumerable<T>

second
IEnumerable<TKey>

傳回其獨特項目同時出現在第一個序列中的 IEnumerable<T>

keySelector
Func<TSource,TKey>

用來擷取各項目之索引鍵的函式。

傳回

IEnumerable<TSource>

序列,其中包含形成兩個序列之交集的項目。

例外狀況

firstsecondnull

備註

這個方法是使用延後執行來實作。 立即傳回值是一個物件,會儲存執行動作所需的所有資訊。 除非直接呼叫其 GetEnumerator 方法或在 C# 或 foreachFor Each Visual Basic 中使用 來列舉物件,否則不會執行這個方法所代表的查詢。

兩組 A 和 B 的交集定義為集合,其中包含同時出現在 B 中的所有 A 元素,但沒有其他元素。

列舉這個方法所傳回的物件時, Intersect 會以出現在 中的順序產生兩個序列中 first 發生的相異專案。

預設相等比較子 Default 是用來比較值。

另請參閱

適用於