|
-
Jan 17th, 2003, 02:42 PM
#1
Thread Starter
Addicted Member
Collection/Structure within Class
I need to have a collection (I think) in my class and I needed some examples or other sites that could help.
I really need to be able to do stuff like:
myClass.layer("red").visible = true
myClass.layer("blue").visible = false
where layer is my collection in my class, red and blue are string keys, visible is a property of the structure, etc. I also need to be able to get/set and add/remove the items.
anyone have any good sites or examples to help?
thanks,
-
Jan 17th, 2003, 02:49 PM
#2
Hyperactive Member
Why not just put a Hashtable inside your class, I do that quite often
Private ColorTable as New HashTable()
Then you can add the objects and remove them as needed by the key color
ColorTable.Add("Red", Object)
-
Jan 17th, 2003, 03:05 PM
#3
Thread Starter
Addicted Member
What's a hashtable?
And color doesn't have anything to do with the actual data, I just used that as an example. There will be +5 properties for each item and I need to be able to get the item by the key. I have some old vb6 code at home that does this using collections, type, and arrays or structures, but I forgot how it worked.
-
Jan 17th, 2003, 03:10 PM
#4
Hyperactive Member
A Hashtable is just another form of a collection, it's basically a collection on steroides.. You can Add ANYTHING to a hashtable, any value, any object, any class. And the hashtable uses keys to sort it's data.. just play with it, you will find it very easy to use..
-
Jan 17th, 2003, 04:30 PM
#5
yay gay
if u know what u'll put as probably u'll know why and if the propriesties are gonna be all the same why not put get / set's?
\m/  \m/
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|