ClassifierTree tree = new ClassifierTree();
foreach (TreeNode Node in Nodes)
{
if (Node.ParentID == 0)
{
tree.Childrens.Add(Node);
Node.Childrens = GetChildsFromList(Node, Nodes);
}
}
private static List<TreeNode> GetChildsFromList(TreeNode Node, List<TreeNode> list)
{
List<TreeNode> childs = new List<TreeNode>();
foreach(TreeNode node in list)
{
if (node.ParentID == Node.ID)
{
childs.Add(node);
node.Childrens = GetChildsFromList(node, list);
}
}
return childs;
}