AsyncEnumerable.ContainsAsync<TSource> Method
Definition
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.
Determines whether a sequence contains a specified element.
public static System.Threading.Tasks.ValueTask<bool> ContainsAsync<TSource>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, TSource value, System.Collections.Generic.IEqualityComparer<TSource>? comparer = default, System.Threading.CancellationToken cancellationToken = default);
static member ContainsAsync : System.Collections.Generic.IAsyncEnumerable<'Source> * 'Source * System.Collections.Generic.IEqualityComparer<'Source> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<bool>
<Extension()>
Public Function ContainsAsync(Of TSource) (source As IAsyncEnumerable(Of TSource), value As TSource, Optional comparer As IEqualityComparer(Of TSource) = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of Boolean)
Type Parameters
- TSource
The type of the elements of source.
Parameters
- source
- IAsyncEnumerable<TSource>
A sequence in which to locate a value.
- value
- TSource
The value to locate in the sequence.
- comparer
- IEqualityComparer<TSource>
An equality comparer to compare values.
- cancellationToken
- CancellationToken
The CancellationToken to monitor for cancellation requests. The default is None.
Returns
true if the source sequence contains an element that has the specified value; otherwise, false.
Exceptions
source
is null
.