TEnumerable.GroupBy<T,TKey,TElement,TResult> Method
Overloads
| GroupBy<T,TKey>(IEnumerable<T>, Func<T,TKey>) |
Groups the elements of a sequence according to a specified key selector function. |
| GroupBy<T,TKey>(IEnumerable<T>, Func<T,TKey>, IEqualityComparer<TKey>) |
Groups the elements of a sequence according to a specified key selector function and compares the keys by using a specified comparer. |
| GroupBy<T,TKey,TElement>(IEnumerable<T>, Func<T,TKey>, Func<T,TElement>) |
Groups the elements of a sequence according to a specified key selector function and projects the elements for each group by using a specified function. |
| GroupBy<T,TKey,TElement>(IEnumerable<T>, Func<T,TKey>, Func<T,TElement>, IEqualityComparer<TKey>) |
Groups the elements of a sequence according to a key selector function. The keys are compared by using a comparer and each group's elements are projected by using a specified function. |
| GroupBy<T,TKey,TResult>(IEnumerable<T>, Func<T,TKey>, Func<TKey,IEnumerable<T>,TResult>) |
Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. |
| GroupBy<T,TKey,TResult>(IEnumerable<T>, Func<T,TKey>, Func<TKey,IEnumerable<T>,TResult>, IEqualityComparer<TKey>) |
Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. The keys are compared by using a specified comparer. |
| GroupBy<T,TKey,TElement,TResult>(IEnumerable<T>, Func<T,TKey>, Func<T,TElement>, Func<TKey,IEnumerable<TElement>,TResult>) |
Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. The elements of each group are projected by using a specified function. |
| GroupBy<T,TKey,TElement,TResult>(IEnumerable<T>, Func<T,TKey>, Func<T,TElement>, Func<TKey,IEnumerable<TElement>,TResult>, IEqualityComparer<TKey>) |
Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. Key values are compared by using a specified comparer, and the elements of each group are projected by using a specified function. |
Groups the elements of a sequence according to a specified key selector function.
class function GroupBy<T,TKey>(const source: IEnumerable<T>; const keySelector: Func<T, TKey>): IEnumerable<IGrouping<TKey,T>>
Type Parameters
- T
The type of the elements of source .
- TKey
The type of the key returned by keySelector .
Parameters
- source
- IEnumerable<T>
A sequence whose elements to group.
- keySelector
- Func<T, TKey>
A function to extract the key for each element.
Returns
A sequence where each element is a group that contains a sequence of elements and a key.
Exceptions
source or keySelector is nil .
Groups the elements of a sequence according to a specified key selector function and compares the keys by using a specified comparer.
class function GroupBy<T,TKey>(const source: IEnumerable<T>; const keySelector: Func<T, TKey>; const comparer: IEqualityComparer<TKey>): IEnumerable<IGrouping<TKey,T>>
Type Parameters
- T
The type of the elements of source .
- TKey
The type of the key returned by keySelector .
Parameters
- source
- IEnumerable<T>
A sequence whose elements to group.
- keySelector
- Func<T, TKey>
A function to extract the key for each element.
- comparer
- IEqualityComparer<TKey>
An equality comparer to compare keys.
Returns
A sequence where each element is a group that contains a collection of elements and a key.
Exceptions
source or keySelector is nil .
Remarks
If comparer is nil , the default equality comparer is
used to compare keys.
Groups the elements of a sequence according to a specified key selector function and projects the elements for each group by using a specified function.
class function GroupBy<T,TKey,TElement>(const source: IEnumerable<T>; const keySelector: Func<T, TKey>; const elementSelector: Func<T, TElement>): IEnumerable<IGrouping<TKey,TElement>>
Type Parameters
- T
The type of the elements of source .
- TKey
The type of the key returned by keySelector .
- TElement
The type of the elements in the grouping.
Parameters
- source
- IEnumerable<T>
A sequence whose elements to group.
- keySelector
- Func<T, TKey>
A function to extract the key for each element.
- elementSelector
- Func<T, TElement>
A function to map each source element to an element in the grouping.
Returns
A sequence where each element is a group that contains a collection of
elements of type TElement and a key.
Exceptions
source or keySelector or elementSelector is nil .
Groups the elements of a sequence according to a key selector function. The keys are compared by using a comparer and each group's elements are projected by using a specified function.
class function GroupBy<T,TKey,TElement>(const source: IEnumerable<T>; const keySelector: Func<T, TKey>; const elementSelector: Func<T, TElement>; const comparer: IEqualityComparer<TKey>): IEnumerable<IGrouping<TKey,TElement>>
Type Parameters
- T
The type of the elements of source .
- TKey
The type of the key returned by keySelector .
- TElement
The type of the elements in the grouping.
Parameters
- source
- IEnumerable<T>
A sequence whose elements to group.
- keySelector
- Func<T, TKey>
A function to extract the key for each element.
- elementSelector
- Func<T, TElement>
A function to map each source element to an element in the grouping.
- comparer
- IEqualityComparer<TKey>
An equality comparer to compare keys.
Returns
A sequence where each element is a group that contains a collection
of elements of type TElement and a key.
Exceptions
source or keySelector or elementSelector is nil .
Remarks
If comparer is nil , the default equality comparer is
used to compare keys.
Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key.
class function GroupBy<T,TKey,TResult>(const source: IEnumerable<T>; const keySelector: Func<T, TKey>; const resultSelector: Func<TKey, IEnumerable<T>, TResult>): IEnumerable<TResult>
Type Parameters
- T
The type of the elements of source .
- TKey
The type of the key returned by keySelector .
- TResult
The type of the result value returned by resultSelector .
Parameters
- source
- IEnumerable<T>
A sequence whose elements to group.
- keySelector
- Func<T, TKey>
A function to extract the key for each element.
- resultSelector
- Func<TKey, IEnumerable<T>, TResult>
A function to create a result value from each group.
Returns
A collection of elements of type TResult where each element
represents a projection over a group and its key.
Exceptions
source or keySelector or resultSelector is nil .
GroupBy<T,TKey,TResult>(IEnumerable<T>, Func<T,TKey>, Func<TKey,IEnumerable<T>,TResult>, IEqualityComparer<TKey>)
Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. The keys are compared by using a specified comparer.
class function GroupBy<T,TKey,TResult>(const source: IEnumerable<T>; const keySelector: Func<T, TKey>; const resultSelector: Func<TKey, IEnumerable<T>, TResult>; const comparer: IEqualityComparer<TKey>): IEnumerable<TResult>
Type Parameters
- T
The type of the elements of source .
- TKey
The type of the key returned by keySelector .
- TResult
The type of the result value returned by resultSelector .
Parameters
- source
- IEnumerable<T>
A sequence whose elements to group.
- keySelector
- Func<T, TKey>
A function to extract the key for each element.
- resultSelector
- Func<TKey, IEnumerable<T>, TResult>
A function to create a result value from each group.
- comparer
- IEqualityComparer<TKey>
An equality comparer to compare keys.
Returns
A collection of elements of type TResult where each element
represents a projection over a group and its key.
Exceptions
source or keySelector or resultSelector is nil .
Remarks
If comparer is nil , the default equality comparer is
used to compare keys.
GroupBy<T,TKey,TElement,TResult>(IEnumerable<T>, Func<T,TKey>, Func<T,TElement>, Func<TKey,IEnumerable<TElement>,TResult>)
Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. The elements of each group are projected by using a specified function.
class function GroupBy<T,TKey,TElement,TResult>(const source: IEnumerable<T>; const keySelector: Func<T, TKey>; const elementSelector: Func<T, TElement>; const resultSelector: Func<TKey, IEnumerable<TElement>, TResult>): IEnumerable<TResult>
Type Parameters
- T
The type of the elements of source .
- TKey
The type of the key returned by keySelector .
- TElement
The type of the elements in each grouping.
- TResult
The type of the result value returned by resultSelector .
Parameters
- source
- IEnumerable<T>
A sequence whose elements to group.
- keySelector
- Func<T, TKey>
A function to extract the key for each element.
- elementSelector
- Func<T, TElement>
A function to map each source element to an element in a grouping.
- resultSelector
- Func<TKey, IEnumerable<TElement>, TResult>
A function to create a result value from each group.
Returns
A collection of elements of type TResult where each element
represents a projection over a group and its key.
Exceptions
source or keySelector or elementSelector or resultSelector is nil .
GroupBy<T,TKey,TElement,TResult>(IEnumerable<T>, Func<T,TKey>, Func<T,TElement>, Func<TKey,IEnumerable<TElement>,TResult>, IEqualityComparer<TKey>)
Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. Key values are compared by using a specified comparer, and the elements of each group are projected by using a specified function.
class function GroupBy<T,TKey,TElement,TResult>(const source: IEnumerable<T>; const keySelector: Func<T, TKey>; const elementSelector: Func<T, TElement>; const resultSelector: Func<TKey, IEnumerable<TElement>, TResult>; const comparer: IEqualityComparer<TKey>): IEnumerable<TResult>
Type Parameters
- T
The type of the elements of source .
- TKey
The type of the key returned by keySelector .
- TElement
The type of the elements in each grouping.
- TResult
The type of the result value returned by resultSelector .
Parameters
- source
- IEnumerable<T>
A sequence whose elements to group.
- keySelector
- Func<T, TKey>
A function to extract the key for each element.
- elementSelector
- Func<T, TElement>
A function to map each source element to an element in a grouping.
- resultSelector
- Func<TKey, IEnumerable<TElement>, TResult>
A function to create a result value from each group.
- comparer
- IEqualityComparer<TKey>
An equality comparer to compare keys.
Returns
A collection of elements of type TResult where each element
represents a projection over a group and its key.
Exceptions
source or keySelector or elementSelector or resultSelector is nil .
Remarks
If comparer is nil , the default equality comparer is
used to compare keys.