如何将类和方法名称作为字符串传递并调用该类的方法?
喜欢
void caller(string myclass, string mymethod){
    // call myclass.mymethod();
}谢谢
发布于 2009-07-13 15:44:21
就像这样:
public object InvokeByName(string typeName, string methodName)
{
    Type callType = Type.GetType(typeName);
    return callType.InvokeMember(methodName, 
                    BindingFlags.InvokeMethod | BindingFlags.Public, 
                    null, null, null);
}您应该根据要调用的方法修改绑定标志,并检查msdn中的Type.InvokeMember方法以确定真正需要什么。
https://stackoverflow.com/questions/1120228
复制相似问题