Created
February 27, 2014 16:28
-
-
Save tugberkugurlu/9253521 to your computer and use it in GitHub Desktop.
Split IEnumerable<T> extension
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 LinqExtensions | |
{ | |
public static IEnumerable<IEnumerable<T>> Split<T>(this IEnumerable<T> list, int parts) | |
{ | |
int i = 0; | |
var splits = from item in list | |
group item by i++ % parts into part | |
select part.AsEnumerable(); | |
return splits; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment