public void ReflectiveVisit(VisitorElement element) { // Use reflection to find and invoke the correct Visit method Type[] types = new Type[] { element.GetType() }; MethodInfo methodInfo = this.GetType().GetMethod("Visit", types); if (methodInfo != null) methodInfo.Invoke(this, new object[] { element }); else Console.WriteLine("Unexpected Visit"); }