IceAzul Posted August 17, 2005 Posted August 17, 2005 I noticed for class like ArrayList implement IList, ICollection, and IEnumerable, instead of just IList which covers them all. Are there any benefits by doing this? Quote
*Experts* Nerseus Posted August 17, 2005 *Experts* Posted August 17, 2005 You have to implement all 3 interfaces if you inherit from IList, as IList is based on the others. -ner Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
IceAzul Posted August 17, 2005 Author Posted August 17, 2005 I understand this, but MS did this: class ArrayList : IList, ICollection, IEnumerable { ... } instead of class ArrayList : IList { ... } You can see this from the object browser. Quote
*Experts* Nerseus Posted August 18, 2005 *Experts* Posted August 18, 2005 I did a quick test - I created a new ClassLibrary with one class that implements IList, compiled, and looked at it. It, too, shows ": IList, ICollection, IEnumerable" so that must be how .NET sees it. That kinda makes sense, as far as reflection goes - if you query a class that implements IList and IList implements ICollection, it stands to reason that querying the class through reflection will show both. -nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.