using System.Collections.Generic;
public static void Main()
var Persons = new List<Person>();
Persons.Add(new Person("Eric"));
Persons[0].Childs = new List<Person>();
Persons[0].Childs.Add(new Person("Tom"));
Persons[0].Childs.Add(new Person("John"));
Persons[0].Childs[0].Childs = new List<Person>();
Persons[0].Childs[0].Childs.Add(new Person("Bill"));
Persons.Add(new Person("John"));
public Person(string name)
public string Name {get;set;}
public List<Person> Childs{get;set;}
public static void DisplayPerson(List<Person> persons)
Stack<Person> personStack = new Stack<Person>();
persons.ForEach(personStack.Push);
while (personStack.Count > 0)
Person item = personStack.Pop();
Console.WriteLine("-" + item.Name + ", Level:" + level);
item.Childs.ForEach(personStack.Push);