indy500fan
asked on
I need to create a dictionary within a dictionary
Friends,
I need to create a dictionary within a dictionary within VB.net
Declaration (I think) will be something like:
Dim DriverList As Dictionary(Of String, Dictionary(Of String, clsLapDetail)
I think...
Now,
What I want to do is create a Dictionary entry for each DriverID in my DriverList.
Now that I have a dictionary for each driver_ID, I need to populate my second dictionary with a key (To be determined) and details for each lap as a driver completes a lap.
clsDetail is defined in the atached code.
What I need specifically, is proper declaration of the dictionary within a dictionary (with the clsLapDetail)
and how to initially populate the initial, base entries.
Looking for VB.net syntax, please.
Thanks in advance.
Eric
I need to create a dictionary within a dictionary within VB.net
Declaration (I think) will be something like:
Dim DriverList As Dictionary(Of String, Dictionary(Of String, clsLapDetail)
I think...
Now,
What I want to do is create a Dictionary entry for each DriverID in my DriverList.
Now that I have a dictionary for each driver_ID, I need to populate my second dictionary with a key (To be determined) and details for each lap as a driver completes a lap.
clsDetail is defined in the atached code.
What I need specifically, is proper declaration of the dictionary within a dictionary (with the clsLapDetail)
and how to initially populate the initial, base entries.
Looking for VB.net syntax, please.
Thanks in advance.
Eric
'Declaration of clsLapDetail:
Public Class clsLapDetail
Public Lap As Integer
Public LapTime As Integer
Public PassingTime As Integer
Public ElapsedTime As Integer
Public LapSpeed As Decimal
End Class
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Nope.
That's just an empty dictionary until you start adding laps to it.
The syntax will be something like If DriverList.ContainsKey(id) Then DriverList(id).Add(lapId, lapDetail)
That's just an empty dictionary until you start adding laps to it.
The syntax will be something like If DriverList.ContainsKey(id)
ASKER
Okay, I guess not, I just tried it.
Now I just need to figure out how to add to each driver's dictionary, lap detail.
New question coming soon.
Now I just need to figure out how to add to each driver's dictionary, lap detail.
New question coming soon.
ASKER
Chaosian is a genius!
Not yet. LOL. Still 150K points to go before I get that designation around here. :)
Glad I could help.
Glad I could help.
ASKER
Ha! you already answered my next question with If DriverList.ContainsKey(id) Then DriverList(id).Add(lapId, lapDetail)
Thank you SO MUCH!
Thank you SO MUCH!
ASKER
I don't need to fill out values for the elements inside clsLapDetail for the initial entry?