Skip to content

Instantly share code, notes, and snippets.

@tugberkugurlu
Created February 27, 2014 16:28
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 tugberkugurlu/9253521 to your computer and use it in GitHub Desktop.
Save tugberkugurlu/9253521 to your computer and use it in GitHub Desktop.
Split IEnumerable<T> extension
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