Legend

Class
Struct
Enum
Interface
Delegate
Constructor
Method
Property
Event
Field

Extension method: TResult? MaxOrNull<TSource, TResult>(this IEnumerable<TSource>, Func<TSource, TResult>)

Declaration

public static TResult? MaxOrNull<TSource, TResult>(
    this IEnumerable<TSource> source,
    Func<TSource, TResult> selector
)

Summary

Invokes a selector on each element of a collection and returns the maximum resulting value, or null if the sequence is empty.

Generic type parameters

TSource The type of the elements of source.
TResult
  • Must derive from: System.ValueType.
  • Must have a default constructor.
  • Must be a non-nullable value type.
The type of the value returned by selector.

Parameters

this IEnumerable<TSource>source A sequence of values to determine the maximum value of.
Func<TSource, TResult>selector A transform function to apply to each element.

Returns

The maximum value in the sequence, or null if the sequence is empty.