GroupBy(TSource, TKey) Method (ParallelQuery(TSource), Func(TSource, TKey), IEqualityComparer(TKey))

Task Parallel System.Threading

Groups in parallel the elements of a sequence according to a specified key selector function and compares the keys by using a specified comparer.

Namespace:  System.Linq
Assembly:  System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function GroupBy(Of TSource, TKey) ( _
	source As ParallelQuery(Of TSource), _
	keySelector As Func(Of TSource, TKey), _
	comparer As IEqualityComparer(Of TKey) _
) As ParallelQuery(Of IGrouping(Of TKey, TSource))
C#
public static ParallelQuery<IGrouping<TKey, TSource>> GroupBy<TSource, TKey>(
	ParallelQuery<TSource> source,
	Func<TSource, TKey> keySelector,
	IEqualityComparer<TKey> comparer
)

Parameters

source
Type: System.Linq..::.ParallelQuery<(Of <(TSource>)>)
An OrderedParallelQuery{TSource} than contains elements to sort.
keySelector
Type: System..::.Func<(Of <(TSource, TKey>)>)
A function to extract a key from an element.
comparer
Type: System.Collections.Generic..::.IEqualityComparer<(Of <(TKey>)>)
An IComparer{TSource} to compare keys.

Type Parameters

TSource
The type of elements of source.
TKey
The type of the key returned by keySelector>.

Return Value

An OrderedParallelQuery{TSource} whose elements are sorted descending according to a key.

Exceptions

ExceptionCondition
System..::.ArgumentNullException source or keySelector is a null reference (Nothing in Visual Basic).

See Also