本文介绍了是List< T> .ForEach()方法到哪里去了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始涉足Windows 8的地铁最近,发现我的老哥们人似乎失踪了。

I started dabbling in Windows 8 metro recently, and found that one of my old buddies seems to have gone missing.

我倾向于使用 .ForEach()方法比我更使用传统的foreach()结构,我很快就意识到pretty的,这个方法不可用。例如,该code不会在一个地铁的应用程序编译:

I tend to use the .ForEach() method more than I use the traditional foreach() construct, and I realized pretty quickly that this method isn't available. For example, this code will not compile under a metro app:

var list = new List<string>();

list.ForEach(System.Diagnostics.Debug.WriteLine);

我已经搜查,看看我能找到的这个任何讨论,但无法。我只是为钝角,或者它实际上去了哪里?

I've searched to see if I could find any discussion of this, but wasn't able to. Am I just being obtuse, or is it actually gone?

推荐答案

It's的确走了:

名单,其中,T&GT; .ForEach已在Metro风格的应用程序中删除。而该方法看似简单它有许多潜在的问题当列表被通过传递给的ForEach方法突变。相反,我们建议您只需使用一个foreach循环。

韦斯·哈格德| .NET框架小组(BCL)| http://blogs.msdn.com/b/bclteam/

Wes Haggard | .NET Framework Team (BCL) | http://blogs.msdn.com/b/bclteam/

很奇怪,但是,它使在文档的外观,其中无处它指出,这种方法不支持.NET为Windows应用商店的应用程序(以前.NET的Metro风格的应用程序)。也许这仅仅是对文档团队的一员的监督。

Very strangely, however, it makes an appearance in the documentation, in which nowhere does it state that this method isn't supported in .NET for Windows Store apps (formerly .NET for Metro-style apps). Perhaps this is just an oversight on part of the documentation team.

这篇关于是List&LT; T&GT; .ForEach()方法到哪里去了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 22:23