Created
April 15, 2020 13:27
-
-
Save greenygh0st/10edfabccb0e6f2c5b89865b4f417b54 to your computer and use it in GitHub Desktop.
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
/// <summary> | |
/// Helper methods for the lists. | |
/// </summary> | |
public static class ListExtensions | |
{ | |
public static List<List<T>> ChunkBy<T>(this List<T> source, int chunkSize) | |
{ | |
return source | |
.Select((x, i) => new { Index = i, Value = x }) | |
.GroupBy(x => x.Index / chunkSize) | |
.Select(x => x.Select(v => v.Value).ToList()) | |
.ToList(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment