IList doesn’t extend IList

Yan Cui
theburningmonk.com
Published in
1 min readFeb 8, 2011

Looking at these two images snapped right off MSDN, what do you notice?

image
image

.

.

.

that IEnumerable<T> extends IEnumerable but IList<T> doesn’t extend IList!?

I know, peculiar isn’t it?

Turns out, it was for a good reason:

“A sequence of integers can be treated as a sequence of objects, by boxing every integer as it comes out of the sequence. But a read-write list of integers cannot 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 fulfill the whole contract of IList, so it does not inherit from it."

Interesting.

--

--

Yan Cui
theburningmonk.com

AWS Serverless Hero. Follow me to learn practical tips and best practices for AWS and Serverless.