AsyncEnumerable.MinAsync<TSource> 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
返回泛型序列中的最小值。
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)
类型参数
- TSource
的元素 source的类型。
参数
- source
- IAsyncEnumerable<TSource>
要确定最小值的值序列。
- comparer
- IComparer<TSource>
要 IComparer<T> 比较的值。
- cancellationToken
- CancellationToken
要 CancellationToken 监视取消请求。 默认值为 None。
返回
ValueTask<TSource>
序列中的最小值。
例外
source 是 null。
实现或source接口中IComparableIComparable<T>没有对象。
注解
如果类型 TSource 实现 IComparable<T>,该方法 MinAsync<TSource>(IAsyncEnumerable<TSource>, IComparer<TSource>, CancellationToken) 使用该实现来比较值。 否则,如果类型 TSource 实现 IComparable,则使用该实现来比较值。
如果 TSource 引用类型且源序列为空或仅包含值 null,则此方法返回 null。