【发布时间】:2010-01-07 05:12:43
【问题描述】:
我正在用 C# 编写一个日志记录类,并想添加进行日志调用的方法。手动执行此操作并不太有吸引力。有没有办法知道当前执行的代码在哪个方法?
提前感谢您的精彩...
格雷格
编辑:使用 MethodBase...
System.Reflection.MethodBase thisMethod = System.Reflection.MethodBase.GetCurrentMethod();
Console.WriteLine("This method is: " + thisMethod.Name);
【问题讨论】: