What is the fastest way to get a MethodBase object?
I have a Type object, and a method name:
Type type;
string methodName;
And i need a MethodBase object for the method "methodName", somewhere in the stack.
This works:MethodBase nemo;
StackTrace st = new StackTrace(); // Behaves poorly...
for(int i =0; i< st.FrameCount; i++ )
{
St开发者_运维百科ackFrame sf = st.GetFrame(i);
if (sf.GetMethod().Name == methodName)
{
nemo = sf.GetMethod();
}
}
But i need a faster approach...
You can write type.GetMethod(methodName)
.
精彩评论