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