【发布时间】:2012-08-27 21:36:18
【问题描述】:
我有一个
List<string>
List<string> students;
students.Add("123Rob");
students.Add("234Schulz");
还有一个
Dictionary<string,string>
Dictionary<string, string> courses = new Dictionary<string, string>();
courses .Add("Rob", "Chemistry");
courses .Add("Bob", "Math");
courses .Add("Holly", "Physics");
courses .Add("Schulz", "Botany");
我现在的目标是获得一个包含值的列表 - {Chemistry,Botany}。
换句话说,我正在尝试获得 LINQ 的等价物
select value from [courses]
where [courses].key in
(
select [courses].key from courses,students where [students].id LIKE '%courses.key%'
)
应该如何构建 LINQ 查询?
【问题讨论】:
-
@L.B 你错了..这不是重复的,请删除 dv
标签: c# linq list dictionary linq-to-objects