TEnumerable.MaxBy<T,TKey> Method
Overloads
| MaxBy<T,TKey>(IEnumerable<T>, Func<T,TKey>) |
Returns the maximum value in a generic sequence according to a specified key selector function. |
| MaxBy<T,TKey>(IEnumerable<T>, Func<T,TKey>, IComparer<TKey>) |
Returns the maximum value in a generic sequence according to a specified key selector function and key comparer. |
Returns the maximum value in a generic sequence according to a specified key selector function.
class function MaxBy<T,TKey>(const source: IEnumerable<T>; const keySelector: Func<T, TKey>): T
Type Parameters
- T
The type of the elements of source .
- TKey
The type of key to compare elements by.
Parameters
- source
- IEnumerable<T>
A sequence of values to determine the maximum value of.
- keySelector
- Func<T, TKey>
A function to extract the key for each element.
Returns
The value with the maximum key in the sequence.
Exceptions
source or keySelector is nil .
Returns the maximum value in a generic sequence according to a specified key selector function and key comparer.
class function MaxBy<T,TKey>(const source: IEnumerable<T>; const keySelector: Func<T, TKey>; const comparer: IComparer<TKey>): T
Type Parameters
- T
The type of the elements of source .
- TKey
The type of key to compare elements by.
Parameters
- source
- IEnumerable<T>
A sequence of values to determine the maximum value of.
- keySelector
- Func<T, TKey>
A function to extract the key for each element.
- comparer
- IComparer<TKey>
The comparer to compare keys.
Returns
The value with the maximum key in the sequence.
Exceptions
source or keySelector or comparer is nil .