我正在尝试输出方法及其操作的日志,如果采取并导致“MyAppLog_ListView”,lisftview 的列标题是
Record#______MethodName__________MethodsOutput
1 ______GetCurrentTime______success(21:10)
2 ______DoSplitString_______faild(not in right Format)
3......................................etc'...
这有助于我调试我的程序,因为它有超过 1500 行代码,至少对我来说有点太复杂了,问题是在字符串中存储方法名称的正确方法是什么
public void MyMethod()
{
do stuff
if (comleted) MyAppLog_ListView_AddRecord(string for the methods name, outputSucces)
else if (faild) MyAppLog_ListView_AddRecord(string for the methods name, outputFail)
}
我如何让 MyMethod().Name 存储在字符串中?
重新编辑:
至于 SidAhmeds 答案:
public void MyMethodName() { do stuff string Mnam = MethodBase.GetCurrentMethod().Name; if (comleted) MyAppLog_ListView_AddRecord(Mnam , outputSucces); else if (faild) MyAppLog_ListView_AddRecord(Mnam , outputFail); }