Right.. so I dont actually know how to title this question but basically I have a node class which I can create children nodes of a parent node (root) but I want to be able to access the lowest node first so the child of the child node and so forth. and work up to the root node (no more functions will be carried out on the root node).
Node Class:
class Node
{
private string id { get; set; }
private Node parent { get; set; }
private List<Node> children { get; set; }
private string type { get; set; }
public Node Parent
{
get
{
return parent;
}
set
{
parent = value;
}
}
public Node(string id)
{
children = new List<Node>();
this.id = id;
}
public Node AddChild(string id)
{
children.Add(new Node(id) { Parent = this });
return children.Last();
}
public Node[] AddChildren(string[] children)
{
return children.Select(c => AddChild(c)).ToArray();
}
public void Flatten(Node node)
{
// Create Flatten here
}
}
This is my attempt at explaining my problem using paint:
I forgot to add to the paint image but level 3 in this case is the level that gets the function done on first
if you have any suggestions it would be greatly appreciated and if you need anymore info please ask. I've been searching for an answer the past 2 days and cant seem to find something that will fit my purpose.
Thanks,
Ryan