开发者

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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜