Batches the source sequence into sized buckets and applies a projection to each bucket.
Declaration Syntax
C# | Visual Basic | Visual C++ |
public static IEnumerable<TResult> Batch<TSource, TResult>( this IEnumerable<TSource> source, int size, Func<IEnumerable<TSource>, TResult> resultSelector )
<ExtensionAttribute> _ Public Shared Function Batch(Of TSource, TResult) ( _ source As IEnumerable(Of TSource), _ size As Integer, _ resultSelector As Func(Of IEnumerable(Of TSource), TResult) _ ) As IEnumerable(Of TResult)
public: [ExtensionAttribute] generic<typename TSource, typename TResult> static IEnumerable<TResult>^ Batch( IEnumerable<TSource>^ source, int size, Func<IEnumerable<TSource>^, TResult>^ resultSelector )
Generic Template Parameters
- TSource
- Type of elements in source sequence.
- TResult
- Type of result returned by resultSelector.
Parameters
- source (IEnumerable<(Of <(<'TSource>)>)>)
- The source sequence.
- size (Int32)
- Size of buckets.
- resultSelector (Func<(Of <(<'IEnumerable<(Of <(<'TSource>)>)>, TResult>)>)>)
- The projection to apply to each bucket.
Return Value
A sequence of projections on 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)