1: // First create an instance of the call stack
   2: StackTrace callStack = new StackTrace();
   3:  
   4: // Next select the frame we want...
   5: // 0 : current frame for the current method
   6: // 1 : Frame that called the current method
   7: // 2 : Frame that called the frame that called the current method
   8: // 3 : ...you get the idea!
   9: StackFrame frame = callStack.GetFrame(1);
  10:  
  11: // Using StackFrame.GetMethod(), which returns a 
  12: // MethodBase object, we can obtain detailed 
  13: // information about about a method
  14: MethodBase method = frame.GetMethod();
  15:  
  16: // Get the declaring type and method names 
  17: string declaringType = method.DeclaringType.Name;
  18: string methodName = method.Name;

相关文章:

  • 2022-12-23
  • 2021-11-25
  • 2021-05-03
  • 2022-12-23
  • 2021-12-04
  • 2021-08-14
  • 2021-10-05
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-10
  • 2022-01-03
  • 2022-02-12
  • 2021-10-03
  • 2022-12-23
  • 2021-11-25
相关资源
相似解决方案