[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

I need to create a dictionary within a dictionary

Posted on 2011-05-07
7
Medium Priority
?
398 Views
Last Modified: 2012-08-14
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

0
Comment
Question by:indy500fan
  • 4
  • 3
7 Comments
 
LVL 24

Accepted Solution

by:
Jeff Certain earned 2000 total points
ID: 35712030
Private DriverList As New Dictionary(Of String, Dictionary(Of String, clsLapDetail)
...
For Each id As String in DriverIdList
    DriverList.Add(id, New Dictionary(Of String, clsLapDetail))
Next
0
 

Author Comment

by:indy500fan
ID: 35712079
Chaosian,

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

0
 
LVL 24

Expert Comment

by:Jeff Certain
ID: 35712089
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)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:indy500fan
ID: 35712114
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.
0
 

Author Closing Comment

by:indy500fan
ID: 35712122
Chaosian is a genius!
0
 
LVL 24

Expert Comment

by:Jeff Certain
ID: 35712124
Not yet. LOL. Still 150K points to go before I get that designation around here. :)

Glad I could help.
0
 

Author Comment

by:indy500fan
ID: 35712172
Ha!  you already answered my next question with If DriverList.ContainsKey(id) Then DriverList(id).Add(lapId, lapDetail)

Thank you SO MUCH!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Integration Management Part 2
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question