加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-15 18:12:36 所属栏目:百科 来源:网络整理
导读:我正在移植一些代码以使用 Windows应用商店应用程序并注意到List T .ForEach方法未包含在.NET Core框架(Windows应用商店应用引用的框架)中. MSDN确认Store Apps不支持它. 我可以很容易地绕过丢失的方法,但在这一点上我只是好奇为什么它丢失了. 解决方法 I ca
我正在移植一些代码以使用 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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读