How to create a list of parent objects where each

2019-07-29 14:56发布

In VB.NET 2010, How would one go about creating a list of Parent classes where each Parent has it's own list of Child classes. Where the list of child classes could be as few as 1 child or as many as a few hundred child objects?

2条回答
2楼-- · 2019-07-29 15:21
Dim ChildList as generic.list(of object)
Dim ParentList as generic.list(of ChildList)

You can do it like above

查看更多
The star\"
3楼-- · 2019-07-29 15:27

Sounds like you need a LinkedList object:

LinkedList Outer;

where ParentType is a class that has another LinkedList object of it own:

Public Class ParentType

    Private myChildren As LinkedList<ChildType>

ChildType in above could even be replaced with "ParentType," if it's a list of the exact same kind of object.

For more detail on LinkedList: http://msdn.microsoft.com/en-us/library/6ky9a64s.aspx

查看更多
登录 后发表回答