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
Syntaxpublic static IEnumerable<IEnumerable<T>> Split<T>(
this IEnumerable<T> source,
int chunkSize,
bool supportReiteration = false
)
<ExtensionAttribute>
Public Shared Function Split(Of T) (
source As IEnumerable(Of T),
chunkSize As Integer,
Optional supportReiteration As Boolean = false
) As IEnumerable(Of IEnumerable(Of T))
public:
[ExtensionAttribute]
generic<typename T>
static IEnumerable<IEnumerable<T>^>^ Split(
IEnumerable<T>^ source,
int chunkSize,
bool supportReiteration = false
)
[<ExtensionAttribute>]
static member Split :
source : IEnumerable<'T> *
chunkSize : int *
?supportReiteration : bool
(* Defaults:
let _supportReiteration = defaultArg supportReiteration false
*)
-> IEnumerable<IEnumerable<'T>>
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:
IEnumerableIEnumerableTIEnumerableT 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).
RemarksSplitT(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.
ExamplesIEnumerable<object> source = ...;
foreach (var chunk in source.Split(1000))
{
LoadObjects(chunk);
}
See Also