Is there any elegant way in LINQ to bucket a collection into a set of lists based on a property
i have a collection of cars. I want to bucket this into separate lists by a property of the car . . .lets say brand.
So if i have a collection of some Ford, some Chevy, some BMW, etc, i want a seperate list for each of those buckets.
something like:
IEnumberable<Car> myCarCollection = GetCollection();
List<IEnumera开发者_开发技巧ble<Car>> buckets = myCarCollection.BucketBy(r=>r.Brand)
does something exist like this or do i need to do this "manually" through loops
return myCarCollection.GroupBy(r => r.Brand);
精彩评论