Link to home
Start Free TrialLog in
Avatar of indy500fan
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
'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

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Jeff Certain
Jeff Certain
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of indy500fan
indy500fan

ASKER

Chaosian,

I don't need to fill out values for the elements inside clsLapDetail for the initial entry?

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)
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.
Chaosian is a genius!
Not yet. LOL. Still 150K points to go before I get that designation around here. :)

Glad I could help.
Ha!  you already answered my next question with If DriverList.ContainsKey(id) Then DriverList(id).Add(lapId, lapDetail)

Thank you SO MUCH!