为什么不ICollection的< T>实现ICollection的? [英] Why doesn't ICollection<T> implement ICollection?

查看:153
本文介绍了为什么不ICollection的< T>实现ICollection的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的IEnumerable< T> 工具的IEnumerable
的ICollection< T> 不执行的ICollection

IEnumerable<T> implements IEnumerable.
But ICollection<T> does not implement ICollection.

什么是这样做的理由和/或说这只是一个监督?

What was the rationale for this and/or was it just an oversight?

推荐答案

正如尼克说,的ICollection 是pretty的无用。

As Nick said, ICollection is pretty much useless.

这些接口都是类似的只有他们的名字, CopyTo从计数都仅有一个共同的特性。 添加删除清除包含的IsReadOnly 已被添加,而 IsSychronized SyncRoot上已被删除。

These interfaces are similar only by their name, CopyTo and Count are the only properties in common. Add, Remove, Clear, Contains and IsReadOnly have been added while IsSychronized and SyncRoot have been removed.

在本质上,的ICollection&LT; T&GT; 是可变的,的ICollection 不是

In essence, ICollection<T> is mutable, ICollection is not.

克日什托夫·Cwalina 有更多关于此的主题

的ICollection&LT; T&GT; 看起来的ICollection ,但它实际上是一个非常不同的抽象。我们发现,的ICollection 是不是非常有用。与此同时,我们也没有那么重presented一读的抽象/写非索引集合。 的ICollection&LT; T&GT; 是这样的抽象,你可以说,的ICollection 没有在通用全球的确切相应的对等; 的IEnumerable&LT; T&GT; 是最接近

ICollection<T> seems like ICollection, but it’s actually a very different abstraction. We found that ICollection was not very useful. At the same time, we did not have an abstraction that represented an read/write non-indexed collection. ICollection<T> is such abstraction and you could say that ICollection does not have an exact corresponding peer in the generic world; IEnumerable<T> is the closest.

这篇关于为什么不ICollection的&LT; T&GT;实现ICollection的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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