Table of Contents

Chunk Method

Definition

Namespace
Cuemon.Extensions.Collections.Generic
Assemblies
Cuemon.Extensions.Collections.Generic.dll
Source
src/Cuemon.Extensions.Collections.Generic/EnumerableExtensions.cs

Chunk<T>(IEnumerable<T>, int)

Returns a chunked IEnumerable<T> sequence with a maximum of the specified size. Default is 128.

public static PartitionerEnumerable<T> Chunk<T>(this IEnumerable<T> source, int size = 128)

Parameters

source IEnumerable<T>

An IEnumerable<T> to extend.

size int

The amount of elements to process at a time.

Returns

PartitionerEnumerable<T>

An IEnumerable<T> that contains no more than the specified size of elements from the source sequence.

Type Parameters

T

The type of the elements of source.

Remarks

The original source is reduced equivalent to the number of elements in the returned sequence.

Exceptions

ArgumentNullException

source is null.

ArgumentException

size is less or equal to 0.