【发布时间】:2021-11-12 18:49:11
【问题描述】:
我有一个学生类如下:
public class Student
{
public string Name { get; set; }
public int? Age { get; set; }
public bool? IsMale { get; set; }
}
并列出将学生分配为字典的课程列表,其中所有课程都存储为:
Dictionary<string, List<Student>>
其中 Key (string) 是课程代码,Value (List) 是注册到该特定课程的学生,所有属性都具有价值。
现在我想简化只有学生姓名的数据集。所以我仍然会有一个Dictionary<string, List<Student>>,其中只为每个Student 对象设置Name 属性。
如何编写这样的 LINQ 查询来获取我需要的数据?
【问题讨论】: