EnumerableExtensions.MaxOrDefault<T> Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Returns the max element based on the provided comparer or the default value when the list is empty
public static T MaxOrDefault<T> (this System.Collections.Generic.IEnumerable<T> items, System.Collections.Generic.IComparer<T> comparer = default);
static member MaxOrDefault : seq<'T> * System.Collections.Generic.IComparer<'T> -> 'T
<Extension()>
Public Function MaxOrDefault(Of T) (items As IEnumerable(Of T), Optional comparer As IComparer(Of T) = Nothing) As T
Type Parameters
- T
The type of the items in the collection.
Parameters
- items
- IEnumerable<T>
Collection of items being evaluated.
- comparer
- IComparer<T>
The comparer used to determine the correct item to return.
Returns
T
Max or default value of T