起始代码: https: //dotnetfiddle.net/lJhMyo
string[] names = { "Burke", "Laptop", "Computer",
"Mobile", "Ahemed", "Sania",
"Kungada", "David","United","Sinshia" };
var empList = new List<Employee> {
new Employee {Name = "Burke", ID = "IHED123"},
new Employee {Name = "David", ID = "QIUHD454"},
new Employee {Name = "Batman", ID = "OIWQE565"},
};
Run Code Online (Sandbox Code Playgroud)
如何构造一个 linq 查询(方法语法)来获取员工姓名位于“names”数组中的所有 Employee 对象?
如果“names”中存在不在 empList 中的字符串,则抛出异常。
编辑:如果 empList 很大并且我想要名称不区分大小写匹配怎么办?