eventprostrategies
asked on
Help with .NET Collections
My .NET collections usually look something like ...
Public Class DogCollection
Inherits System.Collections.Collect ionBase
with typed Add/Remove/Item/Contains methods.
----
I would like to start creating more versatile collections.
I'd like to be able to ...
>> Access values by index or a string key
>> Custom sorting (not just by key)
>> dim dog1 as dog = dogCollection1("Murphy") or dogCollection1(0) ... how do you make make default methods like these? for ex, the ListView has an items collection, the ListViewItems of which can be accessed by listView1.Items(displayInd ex as integer) instead of listView1.Items.Item(displ ayIndex as integer) - it's a nifty shortcut, especially for collections.
----
I'll distrubute points fairly to whoever helps out -- links to good examples are appreciated, too. Just don't post a link to MSDN's System.Collections page or something and expect points. Crazy kids :P
Thanks in advance!
Public Class DogCollection
Inherits System.Collections.Collect
with typed Add/Remove/Item/Contains methods.
----
I would like to start creating more versatile collections.
I'd like to be able to ...
>> Access values by index or a string key
>> Custom sorting (not just by key)
>> dim dog1 as dog = dogCollection1("Murphy") or dogCollection1(0) ... how do you make make default methods like these? for ex, the ListView has an items collection, the ListViewItems of which can be accessed by listView1.Items(displayInd
----
I'll distrubute points fairly to whoever helps out -- links to good examples are appreciated, too. Just don't post a link to MSDN's System.Collections page or something and expect points. Crazy kids :P
Thanks in advance!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i answered my own question re: howto make "Default" collection methods for the "item" property of a collection here:
https://www.experts-exchange.com/questions/21486373/Implement-Default-Class-Method.html
no one really answered howto implement a collection using both an integer indexer and string key for accessing items ... most efficiently. I thank alex for some super basic sorting ... this question's dead tho. i'll award some pts to alex -- cleanup, PAQ this puppy.
https://www.experts-exchange.com/questions/21486373/Implement-Default-Class-Method.html
no one really answered howto implement a collection using both an integer indexer and string key for accessing items ... most efficiently. I thank alex for some super basic sorting ... this question's dead tho. i'll award some pts to alex -- cleanup, PAQ this puppy.
An interesting complete example of a custom collection implementation can be found here: http://advancedcollections.codeplex.com
Cheers
Cheers
-1 if x<y
0 if x=y
1 if x>y
Alex :p