问题
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?
回答1:
Dim ChildList as generic.list(of object)
Dim ParentList as generic.list(of ChildList)
You can do it like above
回答2:
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
来源:https://stackoverflow.com/questions/16244548/how-to-create-a-list-of-parent-objects-where-each-parent-can-have-a-list-of-chil