因此,两者都ListBox.ObjectCollection
实现ListView.ListViewItemCollection
了IList
类,它提供了Add
和Remove
方法,但没有AddRange
, InsertRange
, 或RemoveRange
。但是,ListBox.ObjectCollection
也ListView.ListViewItemCollection
提供了一种AddRange
方法——只是 noInsertRange
或RemoveRange
.
ArrayList
另一方面,查看类,它在实现之上IList
还提供AddRange
、InsertRange
和RemoveRange
。此类和接口的通用形式List<T>
(具有AddRange
、InsertRange
和RemoveRange
)和IList<T>
(仅提供Add
和Remove
)之间存在相同的区别。
我可以理解不提供的IList
和接口等等——它只是一个接口;超出, ,等最低要求的任何内容都是可选的。但是,考虑到和类的方法的有用性,并考虑到它们对和控件的方便程度,我想知道为什么这些控件不存在它们。IList<T>
AddRange
Add
Remove
RemoveAt
*Range
ArrayList
List<T>
ListBox
ListView
有人知道吗?和 的内部实现是否有某些东西InsertRange
使这些方法在某种程度上不那么有效,更复杂,或者在其他方面不太RemoveRange
适合ListBox.ObjectCollection
and ?ListView.ListViewItemCollection
AddRange
需要明确的是:我不是在寻找关于“看起来微软的某个人变得懒惰”的猜测;相反,我想知道是否有人真正知道AddRange
and InsertRange
/之间的合法区别,这可能解释andRemoveRange
中缺少后一种方法。ListBox.ObjectCollection
ListView.ListViewItemCollection