0

I have a class that it is a tree. Something like that:

Node
{
    long Id;
    string Name;
    Node Root;
    Node Parent;
    HashSet<Node> Childrens;
}

I would like to know if there are some way with Linq to get all the childrens of the node, and the children of the children, in sumary, to get the tree or subtree from a node.

I know that with Linq I can do that:

myNode.Childrens.select(x => x.Childrens);

Bit this just would give me the children of the childrens, but not more subnodes, so I would need to get all childrens recursively. Is it possible with linq or perhaps I should implement a method for the Node class that implements that?

Thanks.

Álvaro García
  • 18,114
  • 30
  • 102
  • 193

0 Answers0