|
-
Aug 24th, 2003, 11:25 AM
#1
Thread Starter
Hyperactive Member
Better HashTable or Collection?
It's better to use HashTable or use Colection?
Thx,
Xmas79
Learn, this is the Keyword...
-
Aug 24th, 2003, 12:31 PM
#2
I wonder how many charact
-
Aug 24th, 2003, 06:08 PM
#3
Thread Starter
Hyperactive Member
Right answer... I supposed it depends on the object that I have to hold...
Give me a generic answer: for holding numbers only, strings only, my own classes and so on...
Thx,
Xmas79
Learn, this is the Keyword...
-
Aug 24th, 2003, 06:30 PM
#4
I wonder how many charact
array, hash, collection.....
of course it also depends on how you plan to use these objects...
-
Aug 25th, 2003, 01:49 AM
#5
Thread Starter
Hyperactive Member
What are the main difference between these container?
It's a speed problem? Memory usage?
For example I need one to hold my classes and that is fast...
And another thing: I saw that Collection is part of Microsoft.VisualBasic.dll, it's for compatibility only?
Tnx
Xmas79
Learn, this is the Keyword...
-
Aug 25th, 2003, 08:13 AM
#6
I wonder how many charact
http://www.microsoft.com/belux/nl/ms...lections1.mspx
I have been using strongly-typed collections derived from System.Collections.Collectionbase. How different it is from VisualBasic.Collections I don't know, probably not different in most respects, other than its not VB-specific.
-
Aug 25th, 2003, 02:37 PM
#7
Thread Starter
Hyperactive Member
Thanks nema! Your link made me understanding a lot of things!!!!!!!
Best regards,
Xmas79
Learn, this is the Keyword...
-
Aug 25th, 2003, 03:52 PM
#8
Fanatic Member
A Hashtable is more more flexible.
Because the key can be anything, and not just a string as it is with a Collection.
Data is stored in a Collection in some kind of order, and you can add new items before or after other items. Well a Hashtable, there is no 'order', items are just added. So you don't specify where in the hashtable you should add new items, you simply just add them.
You can access the items using your key, remember the key can be any object, not just string
Sample code
VB Code:
Public Class Class1
End Class
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim h As New Hashtable()
Dim s As String = "String"
Dim p As Integer = 100
Dim obj As New Class1()
h.Add(s, "Blah.1")
h.Add(p, "Blah.2")
h.Add(obj, "Blah.3")
MessageBox.Show(h.Item(s))
MessageBox.Show(h.Item(obj))
notice how I have added 3 string values into the hastable, each with there own data type key.
-
Aug 25th, 2003, 05:09 PM
#9
I wonder how many charact
A Hashtable is more more flexible.
Because the key can be anything, and not just a string as it is with a Collection.
Yes, but a collection class inherited from Systems.Net.Collectionbase can do the same. Obviously, you can do just about anything depending on how you want to implement.
I can have a collection of orders, pass in a collection of customers, and receive all orders pertaining to that collection of customers.
Additionally, you can add items in a collection by just doing a CustomerCollection.Add(someCustomer). Additional calls will put the additional customers after the first call, but if order is not important, it does not matter regardless.
Last edited by nemaroller; Aug 25th, 2003 at 05:20 PM.
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
|