【发布时间】:2018-12-18 03:37:29
【问题描述】:
我需要在网页上显示类似二叉树的结构 用来表示父子关系。与二叉树不同,这棵树可以有多个子节点 并且孩子们可以有更多的孩子,这个过程将一直持续到他们的父母没有孩子为止。
所以,我很困惑我的数据模型应该如何,而且我的想法并没有超出这个范围
public class Parent
{
public string parentName {get;set;} // As their will be one start for this tree, I will have one parent node that will show the parent
public List<string> child {get;set;} // As the parent can have multiple children, I can have a list of string
}
但问题是孩子也可以作为父母,因为他们也可以有孩子。我该怎么办 实现这样的结构。
谢谢
【问题讨论】:
-
我认为这只是一个
tree-view而不是二叉树。 -
子节点不要使用左右指针,而是使用数组
标签: c# asp.net asp.net-mvc-4 tree logic