Enumerable.IntersectBy 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
重载
| 名称 | 说明 |
|---|---|
| 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>)
- Source:
- Intersect.cs
- Source:
- Intersect.cs
- Source:
- Intersect.cs
- Source:
- Intersect.cs
- Source:
- 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其中的不同元素。
- second
- IEnumerable<TKey>
将返回第一 IEnumerable<T> 个序列中显示的不同元素。
- keySelector
- Func<TSource,TKey>
用于提取每个元素的键的函数。
返回
包含构成两个序列集交集的元素的序列。
例外
first 或 second 为 null.
注解
此方法是使用延迟执行实现的。 即时返回值是一个对象,用于存储执行操作所需的所有信息。 除非通过直接调用其 GetEnumerator 方法或在 C# 中使用 foreach 或在 Visual Basic 中使用 For Each 来枚举对象,否则不会执行此方法表示的查询。
两组 A 和 B 的交集定义为包含 A 的所有元素的集,这些元素也显示在 B 中,但没有其他元素。
枚举此方法返回的对象时, Intersect 将按照两 first个序列中出现的顺序生成不同的元素。
默认相等比较器 Default用于比较值。
另请参阅
适用于
IntersectBy<TSource,TKey>(IEnumerable<TSource>, IEnumerable<TKey>, Func<TSource,TKey>, IEqualityComparer<TKey>)
- Source:
- Intersect.cs
- Source:
- Intersect.cs
- Source:
- Intersect.cs
- Source:
- Intersect.cs
- Source:
- 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其中的不同元素。
- 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 的交集定义为包含 A 的所有元素的集,这些元素也显示在 B 中,但没有其他元素。
枚举此方法返回的对象时, Intersect 将按照两 first个序列中出现的顺序生成不同的元素。
comparer如果是null,则使用默认相等比较器Default来比较值。