Skip to content

Instantly share code, notes, and snippets.

@wescleymatos
Last active June 1, 2017 05:11
Show Gist options
  • Save wescleymatos/a7e9955af20fda4e78b1 to your computer and use it in GitHub Desktop.
Save wescleymatos/a7e9955af20fda4e78b1 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