为什么不IList的支持的AddRange
List.AddRange()
存在,但 IList.AddRange()
不。
这令我奇怪的。什么是这背后的原因是什么?
List.AddRange()
exists, but IList.AddRange()
doesn't.
This strikes me as odd. What's the reason behind this?
由于接口768,16容易实现,而不是含有一切,但厨房。如果添加的AddRange
你应该再加入 InsertRange
和 RemoveRange
(对称)。一个更好的问题是,为什么有对的IList&LT没有扩展方法; T>
界面类似于的IEnumerable< T>
接口。 (就地排序
,二分查找
,...将是有益的扩展方法)
Because an interface shoud be easy to implement and not contain "everything but the kitchen". If you add AddRange
you should then add InsertRange
and RemoveRange
(for symmetry). A better question would be why there aren't extension methods for the IList<T>
interface similar to the IEnumerable<T>
interface. (extension methods for in-place Sort
, BinarySearch
, ... would be useful)