In that case, I would also recommend a HashTable (in your first question you
only needed to store a number). An arraylist doesn't have a key value, so
you probably can't use it in this scenario.
To store multiple values for each number, I would recommend to create a
class to do that:
Public Class MyItem
Private _color As String
Private _time As DateTime
Public Sub New(ByVal color As String, ByVal time As DateTime)
Me.Color = color
Me.Time = time
End Sub
Public Property Color() As String
Get
Return _color
End Get
Set(ByVal value As String)
_color = value
End Set
End Property
Public Property Time() As DateTime
Get
Return _time
End Get
Set(ByVal value As DateTime)
_time = value
End Set
End Property
End Class
You can use this class in combination with a HashTable like this:
Dim ht As New Hashtable
'Add items
ht.Add(1, New MyItem("yellow", Now))
ht.Add(2, New MyItem("green", Now))
'Check if key exists
If ht.Contains(1) Then
'...
End If
'Retrieve values
MessageBox.Show(CType(ht(1), MyItem).Color)
--
Greetz
Jan Tielens
________________________________
Read my weblog:
http://weblogs.asp.net/jan
simon said:
Now I have 3 values: number,color and time.
Number is unique and can be key value.
So the hash table is very recomended because I can look If number exists
just with:
_timeSpotHashTable.Contains(number)
Does the arraylist has something similar?
How can I do know, when I have 2 values to store for each number: number and
its color and time.
Thank you for your answer,
Simon