我正在移植一些代码以使用
Windows应用商店应用程序并注意到List< T> .ForEach方法未包含在.NET Core框架(Windows应用商店应用引用的框架)中.
MSDN确认Store Apps不支持它.
我可以很容易地绕过丢失的方法,但在这一点上我只是好奇为什么它丢失了.
解决方法
I can easily get around the missing method,but at this point I’m just curIoUs why it’s missing.
我怀疑它被认为是不必要的臃肿,这可能会更好,而不是在框架中开始,如using foreach
is usually cleaner.
实际上,从该博客文章底部的链接,MSFT在MSDN forums中提供了答案:
List<T>.ForEach
has been removed in Metro style apps. While the method seems simple it has a number of potential problems when the list gets mutated by the method passed to ForEach. Instead it is recommended that you simply use a foreach loop.