问题描述
我刚刚发现.NET Fx现在有3个有用的界面:
我有点困惑为什么不实施 IReadOnlyCollection< T>
?有什么原因,或者微软只是忘了设置了?
UPD
在两个小时后,我发现在BCL中有很多集合,它们具有 .Count
属性,但不实现 IReadOnlyCollection< T& / code>接口。
UPD2
此帖子以及 Immo Landwerth的回答,他在其中说出以下内容
In version 4.5 of the framework, HashSet<T>
does not implement IReadOnlyCollection<out T>
.
This omission was resolved in version 4.6 of the framework (released almost 12 months after the above question was asked).
These corrections are not limited to HashSet<T>
, other collections such as Stack<T>
and Queue<T>
have received these improvements.
Speculation on the reason for any omission is moot. It may be oversight or time pressure but frankly, it is of little consequence. I suspect that even direct input from the Microsoft Development Team would be somewhat subjective, even if we enjoy associated anecdotes.
这篇关于为什么HashSet< T>不实现IReadOnlyCollection< T>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!