摘要:
原文:http://diditwith.net/2006/10/05/PerformanceOfForeachVsListForEach.aspx今天当我用foreach循环迭代一个List<int>时,我发现我变得更加了解性能问题,而以前我会去迭代一个int的ArrayList,我对此感到一点沾沾自喜。得益于泛型所带来的好处,C#编译器可以用System.Collections.Generics.IEnumerator<int>避免大量的装箱(boxing)操作,相比使用老式的System.Collections.IEnumerator。我开始想:这真的是最快的方式吗 阅读全文