AsyncEnumerable.Where Method

Definition

Overloads

Where<TSource>(IAsyncEnumerable<TSource>, Func<TSource,Int32,CancellationToken,ValueTask<Boolean>>)

Filters a sequence of values based on a predicate. Each element's index is used in the logic of the predicate function.

Where<TSource>(IAsyncEnumerable<TSource>, Func<TSource,CancellationToken,ValueTask<Boolean>>)

Filters a sequence of values based on a predicate.

Where<TSource>(IAsyncEnumerable<TSource>, Func<TSource,Boolean>)

Filters a sequence of values based on a predicate.

Where<TSource>(IAsyncEnumerable<TSource>, Func<TSource,Int32,Boolean>)

Filters a sequence of values based on a predicate. Each element's index is used in the logic of the predicate function.

Where<TSource>(IAsyncEnumerable<TSource>, Func<TSource,Int32,CancellationToken,ValueTask<Boolean>>)

Source:
Where.cs

Filters a sequence of values based on a predicate. Each element's index is used in the logic of the predicate function.

C#
public static System.Collections.Generic.IAsyncEnumerable<TSource> Where<TSource>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,int,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<bool>> predicate);

Type Parameters

TSource

The type of the elements of source.

Parameters

source
IAsyncEnumerable<TSource>

An IAsyncEnumerable<T> to filter.

predicate
Func<TSource,Int32,CancellationToken,ValueTask<Boolean>>

A function to test each element for a condition; the second parameter of the function represents the index of the source element.

Returns

IAsyncEnumerable<TSource>

An IAsyncEnumerable<T> that contains elements from the input sequence that satisfy the condition.

Exceptions

predicate is null.

Applies to

.NET 10 and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

Where<TSource>(IAsyncEnumerable<TSource>, Func<TSource,CancellationToken,ValueTask<Boolean>>)

Source:
Where.cs

Filters a sequence of values based on a predicate.

C#
public static System.Collections.Generic.IAsyncEnumerable<TSource> Where<TSource>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,System.Threading.CancellationToken,System.Threading.Tasks.ValueTask<bool>> predicate);

Type Parameters

TSource

The type of the elements of source.

Parameters

source
IAsyncEnumerable<TSource>

An IAsyncEnumerable<T> to filter.

predicate
Func<TSource,CancellationToken,ValueTask<Boolean>>

A function to test each element for a condition.

Returns

IAsyncEnumerable<TSource>

An IAsyncEnumerable<T> that contains elements from the input sequence that satisfy the condition.

Exceptions

predicate is null.

Applies to

.NET 10 and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

Where<TSource>(IAsyncEnumerable<TSource>, Func<TSource,Boolean>)

Source:
Where.cs

Filters a sequence of values based on a predicate.

C#
public static System.Collections.Generic.IAsyncEnumerable<TSource> Where<TSource>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,bool> predicate);

Type Parameters

TSource

The type of the elements of source.

Parameters

source
IAsyncEnumerable<TSource>

An IAsyncEnumerable<T> to filter.

predicate
Func<TSource,Boolean>

A function to test each element for a condition.

Returns

IAsyncEnumerable<TSource>

An IAsyncEnumerable<T> that contains elements from the input sequence that satisfy the condition.

Exceptions

predicate is null.

Applies to

.NET 10 and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

Where<TSource>(IAsyncEnumerable<TSource>, Func<TSource,Int32,Boolean>)

Source:
Where.cs

Filters a sequence of values based on a predicate. Each element's index is used in the logic of the predicate function.

C#
public static System.Collections.Generic.IAsyncEnumerable<TSource> Where<TSource>(this System.Collections.Generic.IAsyncEnumerable<TSource> source, Func<TSource,int,bool> predicate);

Type Parameters

TSource

The type of the elements of source.

Parameters

source
IAsyncEnumerable<TSource>

An IAsyncEnumerable<T> to filter.

predicate
Func<TSource,Int32,Boolean>

A function to test each element for a condition; the second parameter of the function represents the index of the source element.

Returns

IAsyncEnumerable<TSource>

An IAsyncEnumerable<T> that contains elements from the input sequence that satisfy the condition.

Exceptions

predicate is null.

Applies to

.NET 10 and other versions
Product Versions
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided), 10
.NET Standard 2.0 (package-provided)