AsyncEnumerable.SingleAsync Method (System.Linq) (original) (raw)
Definition
Namespace:
Assembly:
System.Linq.AsyncEnumerable.dll
Package:
System.Linq.AsyncEnumerable v10.0.0-preview.5.25277.114
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.
Overloads
SingleAsync(IAsyncEnumerable, Func<TSource,CancellationToken,ValueTask>, CancellationToken) | Returns the only element of a sequence that satisfies a specified condition, and throws an exception if more than one such element exists. |
---|---|
SingleAsync(IAsyncEnumerable, Func<TSource,Boolean>, CancellationToken) | Returns the only element of a sequence that satisfies a specified condition, and throws an exception if more than one such element exists. |
SingleAsync(IAsyncEnumerable, CancellationToken) | Returns the only element of a sequence, and throws an exception if there is not exactly one element in the sequence. |
SingleAsync(IAsyncEnumerable, Func<TSource,CancellationToken,ValueTask>, CancellationToken)
Source:
Source:
Returns the only element of a sequence that satisfies a specified condition, and throws an exception if more than one such element exists.
public static System.Threading.Tasks.ValueTask<TSource> SingleAsync<TSource>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<bool>> predicate, System.Threading.CancellationToken cancellationToken = default);
static member SingleAsync : System.Collections.Generic.IAsyncEnumerable<'Source> * Func<'Source, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<bool>> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<'Source>
<Extension()>
Public Function SingleAsync(Of TSource) (source As IAsyncEnumerable(Of TSource), predicate As Func(Of TSource, CancellationToken, ValueTask(Of Boolean)), Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of TSource)
Type Parameters
TSource
The type of the elements of source.
Parameters
Returns
The single element of the input sequence that satisfies a condition.
Exceptions
More than one element satisfies the condition in predicate
(via the returned task).
Applies to
SingleAsync(IAsyncEnumerable, Func<TSource,Boolean>, CancellationToken)
Source:
Source:
Returns the only element of a sequence that satisfies a specified condition, and throws an exception if more than one such element exists.
public static System.Threading.Tasks.ValueTask<TSource> SingleAsync<TSource>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,bool> predicate, System.Threading.CancellationToken cancellationToken = default);
static member SingleAsync : System.Collections.Generic.IAsyncEnumerable<'Source> * Func<'Source, bool> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<'Source>
<Extension()>
Public Function SingleAsync(Of TSource) (source As IAsyncEnumerable(Of TSource), predicate As Func(Of TSource, Boolean), Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of TSource)
Type Parameters
TSource
The type of the elements of source.
Parameters
predicate
A function to test an element for a condition.
Returns
The single element of the input sequence that satisfies a condition.
Exceptions
More than one element satisfies the condition in predicate
(via the returned task).
Applies to
SingleAsync(IAsyncEnumerable, CancellationToken)
Source:
Source:
Returns the only element of a sequence, and throws an exception if there is not exactly one element in the sequence.
public static System.Threading.Tasks.ValueTask<TSource> SingleAsync<TSource>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, System.Threading.CancellationToken cancellationToken = default);
static member SingleAsync : System.Collections.Generic.IAsyncEnumerable<'Source> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<'Source>
<Extension()>
Public Function SingleAsync(Of TSource) (source As IAsyncEnumerable(Of TSource), Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of TSource)
Type Parameters
TSource
The type of the elements of source.
Parameters
Returns
The single element of the input sequence.
Exceptions
The source
sequence contains more than one element. (via the returned task).