群由In LINQ
class Person { internal int PersonID; internal string car ; }
List<Person> persons;
persons[0] = new Person { PersonID = 1, car = "Ferrari" }; persons[1] = new Person { PersonID = 1, car = "BMW" }; persons[2] = new Person { PersonID = 2, car = "Audi" };
personID
class Result { int PersonID; List<string> cars; }
results[0].PersonID = 1; List<string> cars = results[0].cars; result[1].PersonID = 2; List<string> cars = result[1].cars;
var results = from p in persons group p by p.PersonID into g select new { PersonID = g.Key, // this is where I am not sure what to do
Cats萌萌
元芳怎么了