小编g5i*_*der的帖子

StackFrame.GetMethod().名称

我正在使用此帮助程序来解析当前出于日志记录目的而执行的方法的名称。

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

        return sf.GetMethod().Name;
    }
Run Code Online (Sandbox Code Playgroud)

这是返回的字符串<Frequency>b__46

“ b__46 是什么意思?有没有办法只检索“频率”这个词?

这是在呼叫助手。

    return ProxyCallWrapper.Execute<bool, IBackendJob>((backend, header) =>
    {
        header.CorrelationID = CorrelationID;
        logger.LogInfo(string.Format("### BSL CALL from {0} by {1} : CorrelationID: {2}", this.ToString(), GetCurrentMethod() ,header.CorrelationID));
        return backend.AddJob(header, jobId);
    });
Run Code Online (Sandbox Code Playgroud)

c# stack-trace helpermethods

1
推荐指数
1
解决办法
2427
查看次数

标签 统计

c# ×1

helpermethods ×1

stack-trace ×1