c# - Is there any elegant way in LINQ to bucket a collection into a set of lists based on a property -


i have collection of cars. want bucket separate lists property of car . . .lets brand.

so if have collection of ford, chevy, bmw, etc, want seperate list each of buckets.

something like:

ienumberable<car> mycarcollection = getcollection();  list<ienumerable<car>> buckets = mycarcollection.bucketby(r=>r.brand) 

does exist or need "manually" through loops

return mycarcollection.groupby(r => r.brand); 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -