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

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
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
 
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
 
Back
Top