Look­ing at these two images snapped right off MSDN, what do you notice?

image

image

.

.

.

that IEnumerable<T> extends IEnu­mer­able but IList<T> doesn’t extend IList!?

I know, pecu­liar isn’t it?

 

Turns out, it was for a good reason:

“A sequence of inte­gers can be treated as a sequence of objects, by box­ing every inte­ger as it comes out of the sequence. But a read-write list of inte­gers can­not be treated as a read-write list of objects, because you can put a string into a read-write list of objects. An IList<T> is not required to ful­fill the whole con­tract of IList, so it does not inherit from it.”

Inter­est­ing.

Share

One Response to “IList<T> doesn’t extend IList”

  1. satheesh says:

    Nice explanation.Thanks

Leave a Reply