static void Test3() { Console.WriteLine("----Test3"); ClassD d = new ClassD(); ClassD d2 = new ClassD("Not just a D"); var b = new MDer(d); var b2 = new MDer(); var ctor = b.GetType().GetConstructor(new Type[] { typeof(ClassD) }); if (ctor == null) { Console.WriteLine("Method is null"); return; } TODO: var parameters = ctor.GetParameters(); if (parameters != null) { foreach (var param in parameters) { if (param != null) { Console.WriteLine(param); } else { Console.WriteLine("null"); } } } else { Console.WriteLine("Parameters is null"); } Console.WriteLine("Invoke:"); ctor.Invoke(new object[] { (new ClassD("ClassD: hello, this a D test")) }); //ctor.Invoke(new object[] { (new ClassD("ClassD: hello, this a D test")) }); }
public MDer(ClassD d) { Console.WriteLine(d.msg); }