Прочетете на английски Редактиране

Споделяне чрез


AsyncEnumerable.TakeWhile Method

Definition

Overloads

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

Returns elements from a sequence as long as a specified condition is true.

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

Returns elements from a sequence as long as a specified condition is true. The element's index is used in the logic of the predicate function.

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

Returns elements from a sequence as long as a specified condition is true. The element's index is used in the logic of the predicate function.

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

Returns elements from a sequence as long as a specified condition is true.

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

Source:
TakeWhile.cs

Returns elements from a sequence as long as a specified condition is true.

C#
public static System.Collections.Generic.IAsyncEnumerable<TSource> TakeWhile<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>

A sequence to return elements from.

predicate
Func<TSource,Boolean>

A function to test each element for a condition.

Returns

IAsyncEnumerable<TSource>

An IAsyncEnumerable<T> that contains the elements from the input sequence that occur before the element at which the test no longer passes.

Exceptions

predicate is null.

Applies to

.NET 10 и други версии
Продукт Версии
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

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

Source:
TakeWhile.cs

Returns elements from a sequence as long as a specified condition is true. The element's index is used in the logic of the predicate function.

C#
public static System.Collections.Generic.IAsyncEnumerable<TSource> TakeWhile<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>

A sequence to return elements from.

predicate
Func<TSource,Int32,Boolean>

A function to test each element for a condition.

Returns

IAsyncEnumerable<TSource>

An IAsyncEnumerable<T> that contains the elements from the input sequence that occur before the element at which the test no longer passes.

Exceptions

predicate is null.

Applies to

.NET 10 и други версии
Продукт Версии
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

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

Source:
TakeWhile.cs

Returns elements from a sequence as long as a specified condition is true. The element's index is used in the logic of the predicate function.

C#
public static System.Collections.Generic.IAsyncEnumerable<TSource> TakeWhile<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>

A sequence to return elements from.

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

A function to test each element for a condition.

Returns

IAsyncEnumerable<TSource>

An IAsyncEnumerable<T> that contains the elements from the input sequence that occur before the element at which the test no longer passes.

Exceptions

predicate is null.

Applies to

.NET 10 и други версии
Продукт Версии
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

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

Source:
TakeWhile.cs

Returns elements from a sequence as long as a specified condition is true.

C#
public static System.Collections.Generic.IAsyncEnumerable<TSource> TakeWhile<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>

A sequence to return elements from.

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

A function to test each element for a condition.

Returns

IAsyncEnumerable<TSource>

An IAsyncEnumerable<T> that contains the elements from the input sequence that occur before the element at which the test no longer passes.

Exceptions

predicate is null.

Applies to

.NET 10 и други версии
Продукт Версии
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided), 10
.NET Standard 2.0 (package-provided)