AsyncEnumerable.MinAsync Method (System.Linq) (original) (raw)

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 minimum value in a generic sequence.

public static System.Threading.Tasks.ValueTask<TSource?> MinAsync<TSource>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, System.Collections.Generic.IComparer<TSource>? comparer = default, System.Threading.CancellationToken cancellationToken = default);
static member MinAsync : System.Collections.Generic.IAsyncEnumerable<'Source> * System.Collections.Generic.IComparer<'Source> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<'Source>
<Extension()>
Public Function MinAsync(Of TSource) (source As IAsyncEnumerable(Of TSource), Optional comparer As IComparer(Of TSource) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of TSource)

Type Parameters

TSource

The type of the elements of source.

Parameters

source

IAsyncEnumerable

A sequence of values to determine the minimum value of.

Returns

The minimum value in the sequence.

Exceptions

Remarks

If type TSource implements IComparable, the MinAsync(IAsyncEnumerable, IComparer, CancellationToken) method uses that implementation to compare values. Otherwise, if type TSource implements IComparable, that implementation is used to compare values.

If TSource is a reference type and the source sequence is empty or contains only values that are null, this method returns null.

Applies to