Click or drag to resize

chunkChunkT Method (IEnumerableT, Int32)

Transforms the list by grouping adjacent elements together into a single member.

Namespace:  WhetStone.Looping
Assembly:  WhetStone (in WhetStone.dll) Version: 1.0.4.0 (1.0.0.0)
Syntax
C#
public static IEnumerable<IList<T>> Chunk<T>(
	this IEnumerable<T> this,
	int chunkSize
)

Parameters

this
Type: System.Collections.GenericIEnumerableT
The IEnumerableT to be chunked.
chunkSize
Type: SystemInt32
The size of every chunk.

Type Parameters

T
The type of the IEnumerableT

Return Value

Type: IEnumerableIListT
A new IEnumerableT of IListTs, each of which contains chunkSize elements.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerableT. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Remarks
If the elements don't evenly divide to chunkSize, the last element of the return value will be shorter.
See Also