Skip to content

Instantly share code, notes, and snippets.

@jglozano
Created September 8, 2014 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jglozano/3ae1c31d133c42cbee45 to your computer and use it in GitHub Desktop.
Save jglozano/3ae1c31d133c42cbee45 to your computer and use it in GitHub Desktop.
IEnumerable Chunk
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);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment