Avatar of oak29
oak29
 asked on

Nested Generic List

I'm trying to create a nested  generic list.  My first List consists of a list of datarows.  I would like the first list to be the parent list and then also give this list a child list of datarows but I'm unsure of the syntax or if this is even possible. any ideas?
Visual Basic.NET.NET ProgrammingMicrosoft Development

Avatar of undefined
Last Comment
Nasir Razzaq

8/22/2022 - Mon
Naman Goel

It seems you want List of

 Dim lstDataRows As List(Of List(Of DataRow))

Open in new window



And here I am initializing it:
        lstDataRows = New List(Of List(Of DataRow))

Open in new window


then assignment of datarow to first item of lstDataRows list

 
       lstDataRows.Add(New List(Of DataRow))

Open in new window

oak29

ASKER
I guess I'm not sure how this creates a parent list of datarows with a list of children datarows that are assigned to parent.  Maybe I'm missunderstanding.

Could you show me the syntax for adding the parent row and also adding the child rows in a different list beneath parent.  There can be multiple parent rows.  This is why I want a seperate list for them.
Naman Goel

I think I misunderstood your question itself. Can you please explain your question in detail.

for me nested list means List of List
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
oak29

ASKER
I'm trying to find a way to manage two datatables in memory that relate to each other.  The datarows of the parent table are created by a user button.  I then need to create at the same time multiple datarows that are the children of the parent datarow.

 There can be multiple datarows in the parent table that have their own children rows.  I thought that I could use lists to accomplish this linking.  Is there a better solution for what I'm trying to accomplish?
ASKER CERTIFIED SOLUTION
Nasir Razzaq

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.