XEnumerableBatchTSource Method |
Splits the input sequence into a sequence of batches of the specified size.
Namespace:
Linq.Extras
Assembly:
Linq.Extras (in Linq.Extras.dll) Version: 5.0.0+96a4f4bfed64095342c5df107c1fe1fb95603ee5
Syntaxpublic 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))
[<ExtensionAttribute>]
static member Batch :
source : IEnumerable<'TSource> *
size : int -> IEnumerable<IEnumerable<'TSource>>
Parameters
- source
- Type: System.Collections.GenericIEnumerableTSource
The sequence to split into batches. - size
- Type: SystemInt32
The size of the batches
Type Parameters
- TSource
- The type of the elements of source.
Return Value
Type:
IEnumerableIEnumerableTSourceA sequence of batches of the specified size; the last batch can be shorter if there isn't enough elements remaining in the input sequence.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type
IEnumerableTSource. 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).
See Also