string[] candidates = new string[] {
"Luke_jedi", "Force_unknown",
"Vader_jedi" , "Emperor_human", "r2d2_robot"
};
string[] disregard = new string[] {"_robot", "_jedi"};
//find those that aren't jedi or robots.
var nonJedi = candidates.Where(c=>
c.??? //likely using EndsWith() and Any()
);
如何使用LINQ实现此解决方案,以找到所有不以任何无视项目结束的解决方案?
答案 0 :(得分:7)
var nonJedi = candidates.Where(c => !disregard.Any(d => c.EndsWith(d)));
答案 1 :(得分:0)