星空网 > 软件开发 > ASP.net

LINQ的Any方法

返回布尔值,判断集合中是否有元素满足某一条件。

 
LINQ的Any方法

 
source code:

LINQ的Any方法LINQ的Any方法
IEnumerable<string> str = new List<string> {        "asdf","fgsdfg","tyuiu","ryury","ituyitu"      };      if (str.Any(x => x.EndsWith("iu")))      {        Write("true");      }      else      {        Write("false");      }

View Code


或者你可以如下这样写:
LINQ的Any方法

 

source code:

LINQ的Any方法LINQ的Any方法
IEnumerable<string> str = new List<string> {        "asdf","fgsdfg","tyuiu","ryury","ituyitu"      };      //if (str.Any(x => x.EndsWith("iu")))      //{      //  Write("true");      //}      //else      //{      //  Write("false");      //}      bool blnResult = str.Any();      blnResult = str.Any<string>((s) =>      {        return s.LastIndexOf("iu") > 0;      });      if (blnResult)      {        Write("true");      }      else      {        Write("false");      }

View Code






原标题:LINQ的Any方法

关键词:linq

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

境外开账户:https://www.goluckyvip.com/tag/79110.html
印尼市场潜力:https://www.goluckyvip.com/tag/7912.html
土耳其清关:https://www.goluckyvip.com/tag/7913.html
台湾选品:https://www.goluckyvip.com/tag/7914.html
越南选品:https://www.goluckyvip.com/tag/7915.html
美国版权侵权:https://www.goluckyvip.com/tag/79153.html
TikTok 将推出先买后付服务 :https://www.goluckyvip.com/news/188219.html
深圳有没有比较好玩的景点 深圳有没有比较好玩的景点推荐一下:https://www.vstour.cn/a/366175.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流