Why does ICollection not contain an Add method?

Viewed 3034

As in the title, does anyone know why the ICollection interface does not contain an Add method? It seems very odd that the generic version, ICollection<T>, has an Add but ICollection does not. Anyone with deeper knowledge on this would be really helpful.

As to why I care- unfortunately the developers who build SharePoint have never learned about generics, so every single collection in the API is a a non-generic collection based off of ICollection. I'd like to attach several extension methods to ICollection that involve adding to the collection, among other things, but this seems to be impossible (at least not possible without reflection).

EDIT:

Quite a few people are speculating the reason is because ICollection.Add would require an Object, and thus wouldn't be typesafe. This isn't the case. IList has an Add method that takes an Object. You simply need to do a typecheck and a cast in a method that takes Object.

The argument that an array implements ICollection and therefore it can't have an Add also doesn't hold water. If ICollection had an Add method, it would just need to be explicitly implemented on arrays and throw an Exception (as many of the methods arrays implement currently do).

I was really hoping someone had a reference to an explanation by one of the designers.

8 Answers
Related