c# – 如何使用LINQ查询不包含来自另一个列表的子字符串条目的字符串列表

c# – 如何使用LINQ查询不包含来自另一个列表的子字符串条目的字符串列表,第1张

概述string[] candidates = new string[] { "Luke_jedi", "Force_unknown", "Vader_jedi" , "Emperor_human", "r2d2_robot"};string[] disregard = new string[] {"_robot", "_jedi"};//find those that a
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)));
总结

以上是内存溢出为你收集整理的c# – 如何使用LINQ查询不包含来自另一个列表的子字符串目的字符串列表全部内容,希望文章能够帮你解决c# – 如何使用LINQ查询不包含来自另一个列表的子字符串条目的字符串列表所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1215984.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-05
下一篇 2022-06-05

发表评论

登录后才能评论

评论列表(0条)

保存