Last active
December 26, 2018 09:29
-
-
Save fuqunaga/0e96c2cfdf092bbfd0fba195699a1945 to your computer and use it in GitHub Desktop.
IEnumerableChunks
This file contains hidden or 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 class IEnumerableExtensions | |
{ | |
public static IEnumerable<IEnumerable<T>> Chunks<T>(this IEnumerable<T> list, int size) | |
{ | |
var buf = list; | |
while (buf.Any()) | |
{ | |
yield return buf.Take(size); | |
buf = buf.Skip(size); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment