Source/Extensions/LinqExtensions.cs
/// <summary>
/// Break a list of items into chunks of a specific size
/// </summary>
/// <param name="source">The enumerable to operate on.</param>
/// <returns>Chunks of the specifed size</returns>
Break a list of items into chunks of a specific size
Break a list of items into chunks of a specific size
public static IEnumerable<IEnumerable<T>> Chunk<T>(this IEnumerable<T> source, int chunksize)
		{
			while (source.Any())
			{
				yield return source.Take(chunksize);
				source = source.Skip(chunksize);
			}
		}
public static IEnumerable < IEnumerable < T > > Chunk < T > ( this IEnumerable < T > source , int chunksize ) { while ( source . Any ( ) ) { yield return source . Take ( chunksize ) ; source = source . Skip ( chunksize ) ; } }
Break a list of items into chunks of a specific size
Break a list of items into chunks of a specific size
Chunks of the specifed size
Chunks of the specifed size
IEnumerable<T>
this
chunksize
int
source
The enumerable to operate on.
The enumerable to operate on .