Day pill – c# divide list into sized group

Hi,
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!

1
Leave a Reply

avatar
1 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
1 Comment authors
minneapolis web design Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
minneapolis web design
Guest

Thanks for sharing interesting and informative post.