摘要:        
foreach遍历集合好处很多,因为.net framework在foreach中已经做了try...catch和dispose的操作。那么如果想自定义一个集合并且该集合能使用foreach来遍历,一般做法是实现System.Collections.IEnumerable和System.Collections.IEnumerator接口。其实只要在集合类中实现无参数的返回IEnumerator的GetEnumerator方法就可以了。如下面代码 1 public class MyList 2 { 3 private string[] list=null; 4 public My...    阅读全文
posted @ 2011-12-22 15:14
^_^肥仔John
阅读(325)
评论(0)
推荐(0)
        
                    
                
浙公网安备 33010602011771号