Skip to content

ReadOnlySequenceHelper.Batch(IEnumerable<byte>, int)

Batch(IEnumerable<byte>, int)

staticextension
View source
public static IEnumerable<byte[]> Batch(this IEnumerable<byte> sequence, int batchSize)
Groups a sequence of bytes into arrays containing at most batchSize bytes.

Parameters

sequenceIEnumerable<byte>
The sequence to divide into batches.
batchSizeint
The maximum number of bytes in each batch.

Returns

A sequence of byte arrays containing the source bytes in order.

Exceptions

System.ArgumentNullException
sequence is null.