📜  c# 获取执行方法名称 - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:38.043000             🧑  作者: Mango

代码示例1
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Reflection;

[MethodImpl(MethodImplOptions.NoInlining)]
public string GetCurrentMethod()
{
    var st = new StackTrace();
    var sf = st.GetFrame(1);

    return sf.GetMethod().Name;
}