Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / .NET SDK / October 2003

Tip: Looking for answers? Try searching our database.

Deriving classes from CollectionBase and DictionaryBase

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Hui - 26 Oct 2003 20:06 GMT
Hi,

I am currently deriving strongly types collections and
dictionaries.

The CollectionBase has a protected property "List" that
returns an IList containing the list of elements in the
CollectionBase instance (MSDN).  Is the property "List" a
shallow copy of the actual list implemented withint the
CollectionBase instance?  If I remove elements from the
IList returned from the property "List", will I modify
the elements in the actual CollectionBase?

I have the same question for the protected
property "Dictionary" in the DictionaryBase class.

Any pointers will be helpful.

Thanks in advance.

John Hui
Jay B. Harlow [MVP - Outlook] - 26 Oct 2003 21:30 GMT
John,
The protected CollectionBase.List exposes the IList interface that the class
itself implements. Its easier to use the List property instead of constantly
casting Me or this to IList and using that.

While the CollectionBase.InnerList exposes the ArrayList that the class
maintains.

Invoking operations on either modifies the ArrayList that the class
maintains. However operations on the CollectionBase.List interface will
cause the 9 overridable CollectionBase.On* validation methods to be invoked.

Which means that when you use CollectionBase.List.Add, the
CollectionBase.OnInsert, CollectionBase.OnValidate, and
CollectionBase.OnInsertComplete methods will be called in addition to
modifying the ArrayList. Which allow you to abort the operation.

The DictionaryBase.Dictionary & InnerHashtable have a similar relationship.

Hope this helps
Jay

> Hi,
>
[quoted text clipped - 17 lines]
>
> John Hui
Ying-Shen Yu[MSFT] - 27 Oct 2003 03:48 GMT
Hi John,
CollectionBase.List is just a reference to the CollectionBase object in
IList Type.
So does DictionaryBase.Dictionary.
Does this answer your question?

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!

--------------------
| Content-Class: urn:content-classes:message
| From: "John Hui" <john.hui@noos.fr>
[quoted text clipped - 37 lines]
|
| John Hui

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.