Skip to content

Instantly share code, notes, and snippets.

@Buildstarted
Created February 13, 2013 20:56
Show Gist options
  • Select an option

  • Save Buildstarted/4948184 to your computer and use it in GitHub Desktop.

Select an option

Save Buildstarted/4948184 to your computer and use it in GitHub Desktop.
private static void ForEach<T>(IEnumerable<T> items, int size, Action<IEnumerable<T>, int> action)
{
//temporary list
List<T> internalItems = new List<T>();
int c = 0;
foreach (var item in items)
{
internalItems.Add(item);
c += 1;
if (c == size)
{
action(internalItems, 0);
internalItems.Clear();
c = 0;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment