我有一个Type对象和一个方法名:
Type type;
string methodName; 并且我需要堆栈中某个位置的方法"methodName“的MethodBase对象。
这是可行的:
MethodBase nemo;
StackTrace st = new StackTrace(); // Behaves poorly...
for(int i =0; i< st.FrameCount; i++ )
{
StackFrame sf = st.GetFrame(i);
if (sf.GetMethod().Name == methodName)
{
nemo = sf.GetMethod();
}
}但我需要一个更快的方法。
发布于 2011-05-17 02:18:04
您可以编写type.GetMethod(methodName)。
https://stackoverflow.com/questions/6021558
复制相似问题