thelastmarine

博客园 首页 新随笔 联系 订阅 管理

2012年8月8日 #

摘要: 在下面的示例中,迭代器块(这里是方法 Power(int number, int power))中使用了 yield 语句。当调用 Power 方法时,它返回一个包含数字幂的可枚举对象。注意 Power 方法的返回类型是 IEnumerable(一种迭代器接口类型)。// yield-example.cs using System; using System.Collections; public class List { public static IEnumerable Power(int number, int exponent) { int counter = 0; int r... 阅读全文
posted @ 2012-08-08 20:30 何冲 阅读(136) 评论(0) 推荐(0) 编辑