Method TakeEvery
View SourceTakeEvery<TSource>(IAsyncEnumerable<TSource>, int)
Returns every N-th element of a sequence.
Declaration
public static IAsyncEnumerable<TSource> TakeEvery<TSource>(this IAsyncEnumerable<TSource> source, int step)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | Source sequence |
int | step | Number of elements to bypass before returning the next element. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TSource> | A sequence with every N-th element of the input sequence. |
Type Parameters
Name | Description |
---|---|
TSource | Type of the source sequence |
Remarks
This operator uses deferred execution and streams its results.
Examples
int[] numbers = { 1, 2, 3, 4, 5 };
var result = numbers.TakeEvery(2);
The <code>result</code> variable, when iterated over, will yield 1, 3 and 5, in turn.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentOutOfRangeException | Thrown if |