Once you've grouped the cars by make and model, each element of the sequence is a group. You can get the key for the group with the Key
property, so you can find the group's Make
and Model
, but Year
makes no sense... there will be multiple cars in each group, and they could all have different years. You can use the information within the group, of course. For example:
var groupedCars = cars.GroupBy(a => new { a.Make, a.Model })
.Select(g => new { g.Key.Make, g.Key.Model,
MinYear = g.Min(car => car.Year),
MaxYear = g.Max(car => car.Year) });
But fundamentally you need to be thinking about the fact that each element of the sequence is a group, not a single car.