已有方法:
namespace CAD2008.Functions
{
class CreateSgtExcel
{
public void PCSM(string fileTemplatePath, string projectName, string projectNum)
{
//...
}
}
}
调用方法:
using System;
using System.Reflection;
//反射获取 命名空间+类名
string className = "CAD2008.Functions.CreateSgtExcel";
string methodName = "PCSM";
//传递参数
Object[] paras = new Object[] { templatePath, projectName, projectNum };
Type t = Type.GetType(className);
object obj = Activator.CreateInstance(t);
//直接调用
MethodInfo method = t.GetMethod(methodName);
method.Invoke(obj, paras);