Heike Posted August 19, 2002 Posted August 19, 2002 Can anybody tell me the difference between List and Innerlist in a collectionbase? Thanks Quote
Flyguy Posted August 19, 2002 Posted August 19, 2002 Have a look are at MSDN online: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemcollectionscollectionbaseclasslisttopic.asp Quote
Leaders quwiltw Posted August 21, 2002 Leaders Posted August 21, 2002 I don't think the answer is as easy as just pointing him/her to msdn. I just had a look at the reference and must confess that it's still not entirely clear. It looks like the InnerList just provides you with a specific implementation of the IList and they've also provided the flexibility with the List for CollectionBase implementors to implement an IList interface as they see fit (ie. if an ArrayList wasn't the most efficient structure for your needs). Though it seems that one could implement the List property by simply pointing to the InnerList property. Having said that, it's just a guess, I've not implemented a CollectionBase so I have no firsthand knowledge. Quote --tim
Radovici Posted August 16, 2005 Posted August 16, 2005 I'm a little late to this scene but I feel it's important to close this thread. I came across this thread because I was interested to know the memory and performance implications of choosing one property over the other. The following excerpt from http://msdn.microsoft.com/msdnmag/issues/04/09/AdvancedBasics/ makes it clear. The CollectionBase class provides two properties that allow you to interact with its internal ArrayList: the InnerList property returns an ArrayList reference and the List property returns an IList. The difference between the two is that the List property acts as a wrapper around the InnerList property. When you call the List.Add method, for example, the CollectionBase class first calls its OnValidate and OnInsert overrides, and then calls the InnerList.Add method. After the call to InnerList.Add, the class calls the OnInsertComplete method override. These methods allow you to provide code that runs both before and after the data is inserted into the data structure, and let you validate the data as well. For Adam's example, working with the InnerList property directly is simplest because there's no need to override the other procedures. So InnerList should be minimally better than List. I suppose a remaining option is to inherit the Array type and build the basic functionality [including dynamic resizing, i.e. vector] that I need. Fun. Eldar Quote
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.