1. 首页
  2. 数据库
  3. 其它
  4. 通过实例解析c# yield关键字使用方法

通过实例解析c# yield关键字使用方法

上传者: 2021-04-06 23:41:51上传 PDF文件 399.59KB 热度 9次
1.yield实现的功能 yield return: 先看下面的代码,通过yield return实现了类似用foreach遍历数组的功能,说明yield return也是用来实现迭代器的功能的。 using static System.Console; using System.Collections.Generic; class Program { //一个返回类型为IEnumerable,其中包含三个yield return public static IEnumerable enumerableFuc() { yield return 1;
下载地址
用户评论