为什么不ICollection的< T>实现ICollection的?

编程入门 行业动态 更新时间:2024-10-27 12:35:14
本文介绍了为什么不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的?

本文发布于:2023-11-10 15:40:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1575773.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:ICollection   LT   GT

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!