편집

다음을 통해 공유


EnumerableExtensions.MaxOrDefault<T> Method

Definition

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

Applies to