Search code examples
c#.netilist

Why doesn't IList support AddRange


List.AddRange() exists, but IList.AddRange() doesn't.
This strikes me as odd. What's the reason behind this?


Solution

  • 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)