public static void Main() { Component component = new Composite("root", new Component[] { new Leaf("Leaf A"), new Leaf("Leaf B"), new Composite("Composite X", new Component[] { new Leaf("Leaf XA"), new Leaf("Leaf XB") } ), new Leaf("Leaf C") } ); var visitor = new DisplayVisitor(); Console.WriteLine("{0, -10}{1, -14}{2, -5}", "Type", "Name", "children Count"); Console.WriteLine(new String('-', 40)); component.Accept(visitor); Console.ReadKey(); }