views:

46

answers:

1

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<IEnumerable<Car>> buckets = myCarCollection.BucketBy(r=>r.Brand)

does something exist like this or do i need to do this "manually" through loops

+4  A: 
return myCarCollection.GroupBy(r => r.Brand);
mquander