I have a tree that consists of several objects, where each object has a name (string
), id (int
) and possibly an array of children that are of the same type. How do I go through the entire tree and print out all of the ids and names?
I'm new to programming and frankly, I'm having trouble wrapping my head around this because I don't know how many levels there are. Right now I'm using a foreach
loop to fetch the parent objects directly below the root, but this means I cannot get the children.