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

我正在移植一些代码以使用 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.

相关文章

本文将从上往下,循序渐进的介绍一系列相关.NET的概念,先从...
基于 .NET 的一个全新的、好用的 PHP SDK + Runtime: Pe...
.NET 异步工作原理介绍。
引子 .NET 6 开始初步引入 PGO。PGO 即 Profile Guided Opti...
前言 2021/4/8 .NET 6 Preview 3 发布,这个版本的改进大多来...
前言 开头防杠:.NET 的基础库、语言、运行时团队从来都是相...