为什么ForEach扩展方法在C#中的ObservableCollections中不可用 [英] Why ForEach extension method is not available in ObservableCollections in C#

查看:418
本文介绍了为什么ForEach扩展方法在C#中的ObservableCollections中不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能存在重复:

为什么IEnumerable接口没有ForEach扩展方法?

为什么ForEach扩展方法在ObservableCollections类中不可用,但在List中可用?

Why ForEach extension method is not available in ObservableCollections class while it is available in List ?

推荐答案

正如JJhn所说,这是设计。阅读这篇文章 Lippert了解更多信息。一个标准的 foreach 循环的工作原理也是一样,通常更具可读性。

As JJohn says, it's by design. Read this post by Eric Lippert for more information. A standard foreach loop works just as well and is generally more readable.

这篇关于为什么ForEach扩展方法在C#中的ObservableCollections中不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆