Day pill – c# divide list into sized group

Today i have read on stackoverflow some user that ask how to divide a list into equal part.
So i have decided to write on my blog the code that can help someone.

const int maxSize = 500;
for (int i = 0; i < theList.Count(); i += maxSize) { int takePart = (theList.Count() - i) < maxSize? theList.Count() - i : maxSize; Class[] arrayPart = (from G in theList.Skip(i).Take(maxSize) select new Class {}).toArray(); }

I hope that can help!
Peace and Code!

Leave a Reply

1 Comment authors
minneapolis web design Recent comment authors
newest oldest most voted
Notify of
minneapolis web design

Thanks for sharing interesting and informative post.