// cant modiy this code, it's 3rd libray
public class TestClass{
public void TestMethod(Class2 class2){
}
public void TestMethod(Class3 class3){
}
}
public class Class2{}
public class Class3{}
var Class2Type = System.Reflection.Assembly.GetExecutingAssembly().GetType("Class2");
var TestMethodType = typeof(TestClass).GetMethod("TestMethod",new Type[] { Class2Type });
var del = TestMethodType.CreateDelegate(typeof(Action<,>).MakeGenericType(typeof(TestClass),Class2Type));
// how to invoke TestMethod using del?
if Class2 is a known type, we can invoke TestMethod using del like this:
var del = (Action<TestClass, Class2>)TestMethodType.CreateDelegate(typeof(Action<TestClass, Class2>));
del(new TestClass(), new Class2());
but if "Class2" is unkonwn dynamic string, I dont know how to do it?