แก้ไข

แชร์ผ่าน


AsyncEnumerable.MinAsync<TSource> Method

Definition

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<TSource>

A sequence of values to determine the minimum value of.

comparer
IComparer<TSource>

The IComparer<T> to compare values.

cancellationToken
CancellationToken

The CancellationToken to monitor for cancellation requests. The default is None.

Returns

ValueTask<TSource>

The minimum value in the sequence.

Exceptions

source is null.

No object in source implements the IComparable or IComparable<T> interface.

Remarks

If type TSource implements IComparable<T>, the MinAsync<TSource>(IAsyncEnumerable<TSource>, IComparer<TSource>, 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