Skip to content

Instantly share code, notes, and snippets.

@duydev
Forked from wescleymatos/array_chunk_function.cs
Created October 16, 2016 13:16
Show Gist options
  • Save duydev/6e2327771c358126d0073cecc48eab2e to your computer and use it in GitHub Desktop.
Save duydev/6e2327771c358126d0073cecc48eab2e to your computer and use it in GitHub Desktop.
array chunk c#
public static IEnumerable<IEnumerable<T>> Split<T>(this T[] array, int size)
{
for (var i = 0; i < (float)array.Length / size; i++)
{
yield return array.Skip(i * size).Take(size);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment