using System.Diagnostics;
using System.Reflection;

StackTrace ss = new StackTrace(true);
    string t =ss.GetFrame(2).GetMethod().DeclaringType.ToString()+"."+ss.GetFrame(2).GetMethod().Name;
       return t;

获取2级调用的方法名称,GetFrame(index),index的值讲影响获取的层级方法。

StackTrace ss = new StackTrace(true);
            string t = ss.GetFrame(2).GetMethod().DeclaringType.ToString();
            int index = t.LastIndexOf(".");
            t = t.Remove(index);

获取调用方法的空间名称。t返回的是类名称,包含空间。

相关文章:

  • 2021-06-04
  • 2022-12-23
  • 2022-12-23
  • 2021-10-04
  • 2021-08-12
  • 2022-12-23
猜你喜欢
  • 2022-02-15
  • 2021-11-07
  • 2021-08-29
  • 2022-12-23
  • 2022-12-23
  • 2021-10-19
相关资源
相似解决方案