LINQ的Any方法
2016-04-12 16:50
288 查看
返回布尔值,判断集合中是否有元素满足某一条件。
View Code
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
相关文章推荐
- app framework 内置图标
- 错过是不是一种过错
- 一张图读懂Java多线程
- jquery实现2级联动
- Windows下ADB默认的5037端口被占用,解决方案。
- 45个android实例源码
- Redis-3.0.7_初步解析redis-cli
- Android Studio之maven Central,JCenter
- android网易顶部导航栏demo
- 开灯问题
- c++第三次作业
- 第三次上机作业
- 在Node.js使用mysql模块时遇到的坑
- [Mac]关闭所有打开finder
- codeforces 659A Round House
- MySql中添加用户,新建数据库,用户授权,删除用户,修改密码
- 2016,最值得市场营销人员关注的数字营销策略
- java 中JDK安装与环境变量配置
- 微博主页面布局思路
- 开发当中日期格式的转换(java语言)