14
foreach与someList.ForEach(){}
显然,有很多方法可以迭代集合。好奇是否存在任何差异,或者为什么要使用一种方法来替代另一种方法。 第一类: List<string> someList = <some way to init> foreach(string s in someList) { <process the string> } 另一种方式: List<string> someList = <some way to init> someList.ForEach(delegate(string s) { <process the string> }); 我想想起来,您将可以指定一个可重用的委托,而不是上面使用的匿名委托...
167
c#
.net
generics
loops
enumeration