xiacy

导航

2012年5月10日 #

6.2.2 观察迭代器的工作流程

摘要: static readonly string Padding = new string(' ', 30);static IEnumerable<int> CreateEnumerable(){ Console.WriteLine("{0}start of CreateEnumerable()", Padding); for (int i = 0; i < 3; i++) { Console.WriteLine("{0}about to yield {1}", Padding, i); yield return i; Co 阅读全文

posted @ 2012-05-10 22:52 xiacy 阅读(142) 评论(0) 推荐(0) 编辑

6.2.1 迭代器块和 yield return 简介

摘要: 利用c#2和 yield return 来迭代示例集合class Program{ static void Main(string[] args) { object[] values = { "a", "b", "c", "d", "e" }; IterationSample collection = new IterationSample(values, 1); foreach (object x in collection) { Console.WriteLine(x); } }}... 阅读全文

posted @ 2012-05-10 22:30 xiacy 阅读(269) 评论(0) 推荐(0) 编辑