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

Definition

Namespace:

System.Linq

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

CountAsync(IAsyncEnumerable, Func<TSource,Boolean>, CancellationToken)

Source:

CountAsync.cs

Source:

CountAsync.cs

Returns the number of elements in a sequence satisfy a condition.

public static System.Threading.Tasks.ValueTask<int> CountAsync<TSource>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,bool> predicate, System.Threading.CancellationToken cancellationToken = default);
static member CountAsync : System.Collections.Generic.IAsyncEnumerable<'Source> * Func<'Source, bool> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<int>
<Extension()>
Public Function CountAsync(Of TSource) (source As IAsyncEnumerable(Of TSource), predicate As Func(Of TSource, Boolean), Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of Integer)

Type Parameters

TSource

The type of the elements of source.

Parameters

source

IAsyncEnumerable

A sequence that contains elements to be tested and counted.

predicate

Func<TSource,Boolean>

A function to test each element for a condition.

Returns

The number of elements in the input sequence that satisfy the condition in the predicate function.

Exceptions

The number of elements that satisfy the condition is larger than MaxValue (via the returned task).

Applies to

CountAsync(IAsyncEnumerable, Func<TSource,CancellationToken,ValueTask>, CancellationToken)

Source:

CountAsync.cs

Source:

CountAsync.cs

Returns the number of elements in a sequence satisfy a condition.

public static System.Threading.Tasks.ValueTask<int> CountAsync<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 CountAsync : System.Collections.Generic.IAsyncEnumerable<'Source> * Func<'Source, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<bool>> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<int>
<Extension()>
Public Function CountAsync(Of TSource) (source As IAsyncEnumerable(Of TSource), predicate As Func(Of TSource, CancellationToken, ValueTask(Of Boolean)), Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of Integer)

Type Parameters

TSource

The type of the elements of source.

Parameters

source

IAsyncEnumerable

A sequence that contains elements to be tested and counted.

Returns

The number of elements in the input sequence that satisfy the condition in the predicate function.

Exceptions

The number of elements that satisfy the condition is larger than MaxValue (via the returned task).

Applies to

CountAsync(IAsyncEnumerable, CancellationToken)

Source:

CountAsync.cs

Source:

CountAsync.cs

Returns the number of elements in a sequence.

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

Type Parameters

TSource

The type of the elements of source.

Parameters

source

IAsyncEnumerable

A sequence that contains elements to be counted.

Returns

The number of elements in the input sequence.

Exceptions

The number of elements in source is larger than MaxValue (via the returned task).

Applies to