gpt4 book ai didi

.net - Linq - 是否有我缺少的 IEnumerable.ForEach 扩展方法?

转载 作者:行者123 更新时间:2023-12-05 00:38:12 25 4
gpt4 key购买 nike

<分区>

Possible Duplicates:
Lambda Expression using Foreach Clause…
Why is there not a ForEach extension method on the IEnumerable interface?

这看起来很基础。我试图遍历 IEnumerable 的每个对象。看来我必须先把它放到一个列表中。是对的吗?在我看来,IEnumerable 上应该有一个扩展方法可以做到这一点。我一直不得不纠正自己的错误,我已经厌倦了。我是不是遗漏了什么地方?

myEnumerable.ToList().ForEach(...)

我想这样做:

myEnumerable.ForEach(...)

25 4 0