1
很簡單,因爲在之後開始嵌套的LINQ查詢不表現
var list = new[] {
new { name = "lixiang", age = 14 },
new { name = "lixiang", age = 16 },
new { name = "lidian", age = 14 }
};
var people = list.GroupBy(x => x.name);
這會給我一個編譯器錯誤的代碼作爲,因爲人們預計我的問題是一個記錄的組:
var x1 = people.Select(x => x.name);
但我不明白的是,爲什麼這個成功編譯?
var x2 = people.Select(x => x.Select(y => y.name));