static void Main(string[] args) { var visitor = new Visitor { Value = "12345" }; var intChild = new IntChild(); intChild.AcceptVisitor(visitor); visitor = new Visitor { Value = "1.2345" }; var floatChild = new FloatChild(); floatChild.AcceptVisitor(visitor); visitor = new Visitor { Value = "Hello World" }; var stringChild = new StringChild(); stringChild.AcceptVisitor(visitor); Console.WriteLine("intChild.Value = {0}", intChild.Value); Console.WriteLine("floatChild.Value = {0}", floatChild.Value); Console.WriteLine("stringChild.Value = {0}", stringChild.Value); }
public void Visit(StringChild stringChild) { stringChild.Value = Value.ToString(); }