摘要: 一.IEnumerable、IEnumerable <T>接口C#中对于所有数组,集合都可以用foreach遍历,如:List<string> list=new List<string>();foreach(string str in list){ Console.WriteLine(str);}这是因为这些类都实现了IEnumerable或IEnumerable <T>接口。二.自己写的类,实现IEnumerable接口,用foreach来遍历public class Person:IEnumerable <string>{ pub 阅读全文
posted @ 2013-06-12 19:53 孤独の巡礼 阅读(160) 评论(0) 推荐(0) 编辑