yield return 的使用方法
2024-10-18 17:18:02
以下代码,返回List,list内容为大于60的项
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
IEnumerable<int> arry = A();
List<int> list = arry.ToList();
}
private IEnumerable<int> A() {
int[] scores = new int[] { 55, 56, 57, 58, 59, 69, 70, 33 };
foreach (var item in scores)
{
if (item > 60)
{
yield return item;
}
}
}
最新文章
- JavaScript 的倒计时
- Mysql复合索引
- reference local jar &; customize manifest
- Memcached和Redis对比和适用场景
- cas 单点登录出现org.jasig.cas.client.util.CommonUtils.getResponseFromServer - 拒绝连接 Connection refused
- c#写windows服务(转)
- Java基础之线程——使用Runnable接口(JumbleNames)
- Windows2008下搭建NFS实现windows空间提供linux使用
- hdu5909-Tree Cutting(树形dp)
- VirtualBox NAT方式与主机互相通信
- 【POJ2114】Boatherds 树分而治之
- [Zookeeper研究]一 Zookeeper技术简介
- Redis系列之(二):Redis主从同步,读写分离(转)
- Java面试题-2
- ajax的嵌套需要注意的问题
- 谷歌浏览器把网页打印成pdf
- Mobile Computing: the Next Decade论文 cloudlet薄云
- POJ 2437 Muddy roads【贪心】(区间覆盖)
- 【作业】DS稀疏矩阵
- SpringBoot整合Graylog3.0