public static List<node> findChildren(string parentId, List<testTree> source)
{
List<node> result = new List<node>();
foreach (var item in source)
{
if (item.pid == parentId)
{
node row = new node();
row.data = item.id;
row.name = item.name;
row.subNode=new List<node>();
result.Add(row);
}
}
return result;
}
public static node platToHierarchical(List<testTree> platData, node startNode)
{ List<node> zz = findChildren(startNode.data, platData); foreach (var item in zz)
{
startNode.subNode.Add(platToHierarchical(platData, item));
}
return startNode;
}
{
List<node> result = new List<node>();
foreach (var item in source)
{
if (item.pid == parentId)
{
node row = new node();
row.data = item.id;
row.name = item.name;
row.subNode=new List<node>();
result.Add(row);
}
}
return result;
}
public static node platToHierarchical(List<testTree> platData, node startNode)
{ List<node> zz = findChildren(startNode.data, platData); foreach (var item in zz)
{
startNode.subNode.Add(platToHierarchical(platData, item));
}
return startNode;
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货