gpt4 book ai didi

c# - 为什么 .NET Core 中缺少 List.ForEach?

转载 作者:太空狗 更新时间:2023-10-29 20:59:08 26 4
gpt4 key购买 nike

我正在移植一些代码以使用 Windows 应用商店应用程序并注意到 List<T>.ForEach方法未包含在 .NET Core 框架(Windows 应用商店应用程序引用的框架)中。

MSDN 确认商店应用程序不支持它。

我可以轻松绕过缺少的方法,但此时我只是好奇为什么缺少它。

最佳答案

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.

关于c# - 为什么 .NET Core 中缺少 List<T>.ForEach?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13212259/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com