語言

AsyncEnumerable.IntersectBy 方法

定義

多載

IntersectBy<TSource,TKey>(IAsyncEnumerable<TSource>, IAsyncEnumerable<TKey>, Func<TSource,CancellationToken,ValueTask<TKey>>, IEqualityComparer<TKey>)

來源:
IntersectBy.cs
來源:
IntersectBy.cs
來源:
IntersectBy.cs
來源:
IntersectBy.cs

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

public static System.Collections.Generic.IAsyncEnumerable<TSource> IntersectBy<TSource,TKey>(this System.Collections.Generic.IAsyncEnumerable<TSource> first, System.Collections.Generic.IAsyncEnumerable<TKey> second, Func<TSource,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<TKey>> keySelector, System.Collections.Generic.IEqualityComparer<TKey>? comparer = default);
static member IntersectBy : System.Collections.Generic.IAsyncEnumerable<'Source> * System.Collections.Generic.IAsyncEnumerable<'Key> * Func<'Source, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<'Key>> * System.Collections.Generic.IEqualityComparer<'Key> -> System.Collections.Generic.IAsyncEnumerable<'Source>
<Extension()>
Public Function IntersectBy(Of TSource, TKey) (first As IAsyncEnumerable(Of TSource), second As IAsyncEnumerable(Of TKey), keySelector As Func(Of TSource, CancellationToken, ValueTask(Of TKey)), Optional comparer As IEqualityComparer(Of TKey) = Nothing) As IAsyncEnumerable(Of TSource)

類型參數

TSource

輸入序列元素的類型。

TKey

識別元素的鍵型。

參數

first
IAsyncEnumerable<TSource>

IAsyncEnumerable<T>一個同時出現在 的 second S 中,其獨特元素也會被回傳。

second
IAsyncEnumerable<TKey>

IAsyncEnumerable<T>一個同時出現在第一個序列中的不同元素會被回傳。

keySelector
Func<TSource,CancellationToken,ValueTask<TKey>>

一個用來提取每個元素鍵值的函式。

comparer
IEqualityComparer<TKey>

還有 IEqualityComparer<T> 比較鑰匙。

傳回

IAsyncEnumerable<TSource>

包含構成兩個序列交集集合元素的序列。

例外狀況

keySelector 是 null。

備註

此方法透過延遲執行實現。 立即回傳值是一個物件,儲存執行動作所需的所有資訊。 此方法所表示的查詢,直到物件被枚舉,無論是直接呼叫其「GetEnumerator」方法,或在 Visual C# 中使用「foreach」或在 Visual Basic 中使用「For Each」,才會執行查詢。

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

當此方法回傳的物件被枚舉時,「交集」會產生兩個序列中出現的不同元素,且它們在序列中 first出現的順序相同。

若 comparer , null則預設等式比較器 Default,用於比較數值。

適用於

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

來源:
IntersectBy.cs
來源:
IntersectBy.cs
來源:
IntersectBy.cs
來源:
IntersectBy.cs

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

public static System.Collections.Generic.IAsyncEnumerable<TSource> IntersectBy<TSource,TKey>(this System.Collections.Generic.IAsyncEnumerable<TSource> first, System.Collections.Generic.IAsyncEnumerable<TKey> second, Func<TSource,TKey> keySelector, System.Collections.Generic.IEqualityComparer<TKey>? comparer = default);
static member IntersectBy : System.Collections.Generic.IAsyncEnumerable<'Source> * System.Collections.Generic.IAsyncEnumerable<'Key> * Func<'Source, 'Key> * System.Collections.Generic.IEqualityComparer<'Key> -> System.Collections.Generic.IAsyncEnumerable<'Source>
<Extension()>
Public Function IntersectBy(Of TSource, TKey) (first As IAsyncEnumerable(Of TSource), second As IAsyncEnumerable(Of TKey), keySelector As Func(Of TSource, TKey), Optional comparer As IEqualityComparer(Of TKey) = Nothing) As IAsyncEnumerable(Of TSource)

類型參數

TSource

輸入序列元素的類型。

TKey

識別元素的鍵型。

參數

first
IAsyncEnumerable<TSource>

IAsyncEnumerable<T>一個同時出現在 的 second S 中,其獨特元素也會被回傳。

second
IAsyncEnumerable<TKey>

IAsyncEnumerable<T>一個同時出現在第一個序列中的不同元素會被回傳。

keySelector
Func<TSource,TKey>

一個用來提取每個元素鍵值的函式。

comparer
IEqualityComparer<TKey>

還有 IEqualityComparer<T> 比較鑰匙。

傳回

IAsyncEnumerable<TSource>

包含構成兩個序列交集集合元素的序列。

例外狀況

keySelector 是 null。

備註

此方法透過延遲執行實現。 立即回傳值是一個物件,儲存執行動作所需的所有資訊。 此方法所表示的查詢,直到物件被枚舉,無論是直接呼叫其「GetEnumerator」方法,或在 Visual C# 中使用「foreach」或在 Visual Basic 中使用「For Each」,才會執行查詢。

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

當此方法回傳的物件被枚舉時,「交集」會產生兩個序列中出現的不同元素,且它們在序列中 first出現的順序相同。

若 comparer , null則預設等式比較器 Default,用於比較數值。

適用於