Skip to content

M_CodeJam_Collections_EnumerableExtensions_DistinctBy__2

Andrew Koryavchenko edited this page Jun 17, 2018 · 8 revisions

EnumerableExtensions.DistinctBy(TSource, TKey) Method (IEnumerable(TSource), Func(TSource, TKey))

Returns a sequence with distinct elements from the input sequence based on the specified key.

Namespace: CodeJam.Collections
Assembly: CodeJam (in CodeJam.dll) Version: 2.1.0.0

Syntax

C#

public static IEnumerable<TSource> DistinctBy<TSource, TKey>(
	this IEnumerable<TSource> source,
	Func<TSource, TKey> keySelector
)

VB

<ExtensionAttribute>
Public Shared Function DistinctBy(Of TSource, TKey) ( 
	source As IEnumerable(Of TSource),
	keySelector As Func(Of TSource, TKey)
) As IEnumerable(Of TSource)

F#

[<ExtensionAttribute>]
static member DistinctBy : 
        source : IEnumerable<'TSource> * 
        keySelector : Func<'TSource, 'TKey> -> IEnumerable<'TSource> 

Parameters

 

source
Type: System.Collections.Generic.IEnumerable(TSource)
The sequence to return distinct elements from.
keySelector
Type: System.Func(TSource, TKey)
A function to extract the key for each element.

Type Parameters

 

TSource
[Missing documentation for "M:CodeJam.Collections.EnumerableExtensions.DistinctBy2(System.Collections.Generic.IEnumerable{0},System.Func{0,1})"]
TKey
[Missing documentation for "M:CodeJam.Collections.EnumerableExtensions.DistinctBy2(System.Collections.Generic.IEnumerable{0},System.Func{0,1})"]

Return Value

Type: IEnumerable(TSource)
An IEnumerable(T) that contains distinct elements from the source sequence.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerable(TSource). When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

See Also

Reference

EnumerableExtensions Class
DistinctBy Overload
CodeJam.Collections Namespace

Clone this wiki locally