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.

MaxBy<T,TKey>(IEnumerable<T>, Func<T,TKey>)

Returns the maximum value in a generic sequence according to a specified key selector function.

Delphi
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

T

The value with the maximum key in the sequence.

Exceptions

source or keySelector is nil .

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.

Delphi
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

T

The value with the maximum key in the sequence.

Exceptions

source or keySelector or comparer is nil .