这样可以将要用到的类和方法配置到设置文件中,有的时候很方便
![]()
Code
//格式为(命名空间.类名,程序集名)
object ObjApi = Activator.CreateInstance(Type.GetType("SisComputeAPI.Configs,SisComputeAPI"));
//组织要调用方法的输入参数
object[] args = new object[3];
args[0] = str1;
args[1] = int1;
args[2] = obj1;
//调用方法,传入参数,取得返回值
MethodInfo MyMethod= ObjApi.GetType().GetMethod(MethodName); //MethodName是类ObjApi 中准备调用的方法名
if (MyMethod != null)
{
object result = MyMethod.Invoke(ObjApi , args);
}