Method Batch
Batch<TSource>(IAsyncEnumerable<TSource>, int)
Split the elements of a sequence into chunks of size at most size.
Declaration
public static IAsyncEnumerable<IList<TSource>> Batch<TSource>(this IAsyncEnumerable<TSource> source, int size)
Parameters
| Type | Name | Description |
|---|---|---|
| IAsyncEnumerable<TSource> | source | An IAsyncEnumerable<T> whose elements to chunk. |
| int | size | The maximum size of each chunk. |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<IList<TSource>> | An IAsyncEnumerable<T> that contains the elements the input sequence split into chunks of size size. |
Type Parameters
| Name | Description |
|---|---|
| TSource | The type of the elements of |
Remarks
A chunk can contain fewer elements than size, specifically the final buffer of source.
Returned subsequences are buffered, but the overall operation is streamed.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ArgumentOutOfRangeException |
|