What is the point to use List when InnerList gives more in CollectionBase class

T

Tony Johansson

Hi!

The purpose of CollectionBase is to create a custom collectionclass that
derivs from CollectionBase
In the CollectionBase class there are two members called List and InnerList.
List return an IList and InnerList is an ArrayList.
I just wonder what is the point to use List because InnerList contain all
that exist in List + some more.

//Tony
 
P

Peter Duniho

Tony said:
Hi!

The purpose of CollectionBase is to create a custom collectionclass that
derivs from CollectionBase
In the CollectionBase class there are two members called List and InnerList.
List return an IList and InnerList is an ArrayList.
I just wonder what is the point to use List because InnerList contain all
that exist in List + some more.

Seems to me that the docs are pretty clear at least with respect to one
major reason to use the List property instead of InnerList:

The On* methods are invoked only on the instance returned
by the List property, but not on the instance returned by
the InnerList property.

In other words, if you want your own derived collection class to be able
to detect changes to the underlying list data structure, you need to use
the IList implementation retrieved from the List property, not the
ArrayList you get back from InnerList.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top