Batches the source sequence into sized buckets.
Declaration Syntax
C# | Visual Basic | Visual C++ |
public static IEnumerable<IEnumerable<TSource>> Batch<TSource>( this IEnumerable<TSource> source, int size )
<ExtensionAttribute> _ Public Shared Function Batch(Of TSource) ( _ source As IEnumerable(Of TSource), _ size As Integer _ ) As IEnumerable(Of IEnumerable(Of TSource))
public: [ExtensionAttribute] generic<typename TSource> static IEnumerable<IEnumerable<TSource>^>^ Batch( IEnumerable<TSource>^ source, int size )
Generic Template Parameters
- TSource
- Type of elements in source sequence.
Parameters
- source (IEnumerable<(Of <(<'TSource>)>)>)
- The source sequence.
- size (Int32)
- Size of buckets.
Return Value
A sequence of equally sized buckets containing elements of the source collection.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerable<(Of <(<'TSource>)>)>. When you use instance method syntax to call this method, omit the first parameter.
Remarks
This operator uses deferred execution and streams its results (buckets and bucket content).
Assembly: MoreLinq (Module: MoreLinq.dll) Version: 1.0.16006.0 (1.0.16006.1845)