你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
IEnumerableExtensions.Distinct<TSource,TKeyType> Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Returns a distinct collection based on a key.
public static System.Collections.Generic.IEnumerable<TSource> Distinct<TSource,TKeyType> (this System.Collections.Generic.IEnumerable<TSource> source, Func<TSource,TKeyType> keySelector, System.Collections.Generic.IEqualityComparer<TKeyType> comparer = default);
static member Distinct : seq<'Source> * Func<'Source, 'KeyType> * System.Collections.Generic.IEqualityComparer<'KeyType> -> seq<'Source>
<Extension()>
Public Iterator Function Distinct(Of TSource, TKeyType) (source As IEnumerable(Of TSource), keySelector As Func(Of TSource, TKeyType), Optional comparer As IEqualityComparer(Of TKeyType) = Nothing) As IEnumerable(Of TSource)
Type Parameters
- TSource
The source type.
- TKeyType
The key type.
Parameters
- source
- IEnumerable<TSource>
The source collection.
- keySelector
- Func<TSource,TKeyType>
The key selector.
- comparer
- IEqualityComparer<TKeyType>
The comparer.
Returns
IEnumerable<TSource>