How to create a list of parent objects where each parent can have a list of child objects?

冷暖自知 提交于 2020-01-06 03:26:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!