Enumerable.IntersectBy 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
| 名稱 | Description |
|---|---|
| IntersectBy<TSource,TKey>(IEnumerable<TSource>, IEnumerable<TKey>, Func<TSource,TKey>) |
根據指定的索引鍵選取器函式,產生兩個序列的集合交集。 |
| IntersectBy<TSource,TKey>(IEnumerable<TSource>, IEnumerable<TKey>, Func<TSource,TKey>, IEqualityComparer<TKey>) |
根據指定的索引鍵選取器函式,產生兩個序列的集合交集。 |
IntersectBy<TSource,TKey>(IEnumerable<TSource>, IEnumerable<TKey>, Func<TSource,TKey>)
- 來源:
- Intersect.cs
- 來源:
- Intersect.cs
- 來源:
- 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>
IEnumerable<T>一個同時出現在 的 second S 中,其獨特元素也會被回傳。
- second
- IEnumerable<TKey>
IEnumerable<T>一個同時出現在第一個序列中的不同元素會被回傳。
- keySelector
- Func<TSource,TKey>
一個用來提取每個元素鍵值的函式。
傳回
包含構成兩個序列交集集合元素的序列。
例外狀況
first 或 second 為 null。
備註
此方法透過延遲執行實現。 立即回傳值是一個物件,儲存執行動作所需的所有資訊。 此方法所代表的查詢,直到物件被枚舉,無論是直接呼叫其 GetEnumerator 方法,或是使用 C# 中的 foreach,或在 Visual Basic 中使用 For Each,才會執行。
兩個集合 A 與 B 的交集定義為包含所有同時出現在 B 中的 A 元素,但不含其他元素的集合。
當此方法回傳的物件被列舉時, Intersect 會產生兩個序列中出現的不同元素,並依其出現的 first順序出現。
預設的等號比較器 Default,用於比較數值。
另請參閱
適用於
IntersectBy<TSource,TKey>(IEnumerable<TSource>, IEnumerable<TKey>, Func<TSource,TKey>, IEqualityComparer<TKey>)
- 來源:
- Intersect.cs
- 來源:
- Intersect.cs
- 來源:
- 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>
IEnumerable<T>一個同時出現在 的 second S 中,其獨特元素也會被回傳。
- second
- IEnumerable<TKey>
IEnumerable<T>一個同時出現在第一個序列中的不同元素會被回傳。
- keySelector
- Func<TSource,TKey>
一個用來提取每個元素鍵值的函式。
- comparer
- IEqualityComparer<TKey>
還有 IEqualityComparer<T> 比較鑰匙。
傳回
包含構成兩個序列交集集合元素的序列。
例外狀況
first 或 second 為 null。
備註
此方法透過延遲執行實現。 立即回傳值是一個物件,儲存執行動作所需的所有資訊。 此方法所代表的查詢,直到物件被枚舉,無論是直接呼叫其 GetEnumerator 方法,或是使用 C# 中的 foreach,或在 Visual Basic 中使用 For Each,才會執行。
兩個集合 A 與 B 的交集定義為包含所有同時出現在 B 中的 A 元素,但不含其他元素的集合。
當此方法回傳的物件被列舉時, Intersect 會產生兩個序列中出現的不同元素,並依其出現的 first順序出現。
若 comparer , null則預設等式比較器 Default,用於比較數值。