【发布时间】:2011-07-05 17:35:23
【问题描述】:
可能重复:
is there a .Each() (or .ForEach() ) iterator in the .Net standard library?
也许我错了,但我在 .net (3.0) 中没有看到“EACH”功能?
我们可以
IEnumerable<T>.Select().Where().First().Any()
为什么我们没有
IEnumberable<T>.Each(Action<T> action)?
所以不是两行:
Foreach(T t in list)
action(t);
我们可以打电话
list.Each((t)=>{blah;blah;})?
是否存在性能问题?
【问题讨论】:
-
链接副本上的答案涵盖了这个
-
查看this question 并给出答案。