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=
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实现此解决方案,以找到所有不以任何无视项目结束的解决方案?
var nonJedi = candidates.Where(c => !disregard.Any(d => c.EndsWith(d)));
