Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why ArrayList implement IList, ICollection, IEnumerable?

Tags:

c#

interface

ArrayList declares that it implements the IList, ICollection, and IEnumeralbe interfaces.

Why not only implement IList, because IList is also derived from ICollection, and ICollection is derived from IEnumerable.

What's the purpose of this kind of declaration? There are many cases like this in .NET BCL.

like image 824
Ji Yalin Avatar asked Jul 22 '09 11:07

Ji Yalin


1 Answers

There is no effective difference. I believe the extra declarations are there for clarity.

When checked in Reflector, classes which in code implement IList have the same interface declaration list as classes which in code declare implementing all of Ilist, ICollection and IEnumerable.

like image 53
Kenan E. K. Avatar answered Oct 07 '22 20:10

Kenan E. K.