|
-
Jan 9th, 2003, 01:21 PM
#1
Thread Starter
Hyperactive Member
Hashtable -vs- Array/Collection?
Is there any benifit in using a hashtable to store instances of classes rather than a collection or an arraylist/array? From what I can tell, a hashtable is a suped up version of an array? Is this right?
-
Jan 9th, 2003, 01:39 PM
#2
Frenzied Member
Hashtable is a collection of keys and objects. When an object is inserted into a hashtable, it has to have a key. So if you wanted to get that object back, you would just provide the key and get the corresponding object.
This cant be done in an Arraylist.
Dont gain the world and lose your soul
-
Jan 9th, 2003, 01:43 PM
#3
and a HashTable IS a collection
-
Jan 9th, 2003, 02:00 PM
#4
Thread Starter
Hyperactive Member
Hmm, Ok so if a Hashtable "IS" a collection, how is the speed on a Hashtable? I'm wondering if a Hashtable would be suitable for storing TCPClient Connections in? There would be alot of enumeration in the Hashtable so would it be worth using it? Going back to the old VB6 days, Collections were heavily avoided because of its lack of speed but maybe that has changed in .Net? Can anyone confirm or deny this?
-
Jan 9th, 2003, 02:19 PM
#5
HashTable is still based on the CollectionBase, actually two of them (one for keys and one for values) so I don't think its any faster. I personally would just choose the easiest tool to work with because they are all collection based so I doubt you'd notice much of a speed difference.
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
|