.net - Use linq to break up list<t> into lots of list<t> of n length? -


possible duplicate:
how can split ienumerable<string> groups of ienumerable<string>

i have list break groups of 10.

if have object

list<person> allpendingpersons  

that of length m.

is there elegant way in linq break allpendingpersons 1 or more list objects have 10 persons?

 var groups = allpendingpersons.select((p, index) => new {p,index})                                .groupby(a =>a.index/10 ); 

if want process igrouping<,>. if looking list> try

var listoflists = allpendingpersons.select((p, index) => new {p, index})     .groupby(a => a.index/10)     .select((grp => grp.select(g => g.p).tolist()))     .tolist(); 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -