Click or drag to resize

SplitterSplitT Method

Splits the input IEnumerable in chunks with the specified size.

Namespace:  Aloe.SystemFrameworks.Domain
Assembly:  Aloe.SystemFrameworks.Domain (in Aloe.SystemFrameworks.Domain.dll) Version: 20.1.3.5
Syntax
public static IEnumerable<IEnumerable<T>> Split<T>(
	this IEnumerable<T> source,
	int chunkSize,
	bool supportReiteration = false
)

Parameters

source
Type: System.Collections.GenericIEnumerableT
The source IEnumerableT.
chunkSize
Type: SystemInt32
Size of the chunk.
supportReiteration (Optional)
Type: SystemBoolean
true to support reiteration of individual chunks. Reiteration support involves caching of data, so it should be used only when necessary.

Type Parameters

T

Return Value

Type: IEnumerableIEnumerableT
IEnumerableT of chunks, with each chunk containing 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
SplitT(IEnumerableT, Int32, Boolean) iterates only once over the stream of elements and returns chunks of elements. Each chunk (except the last) contains the specified number of elements. The chunks do not support re-iteration - e.g. only one foreach iteration over the elements of a chunk is supported.
Examples
IEnumerable<object> source = ...;
//process the input stream in chunks of 1000 elements
foreach (var chunk in source.Split(1000))
{
//each resulting chunk is of the same IEnumerable type as the source IEnumerable
//LoadObjects accepts an IEnumerable<object> parameter
LoadObjects(chunk);
}
See Also