Created
September 8, 2014 12:42
-
-
Save jglozano/3ae1c31d133c42cbee45 to your computer and use it in GitHub Desktop.
IEnumerable Chunk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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