私は、メソッドとそのアクションのログを出力しようとしています。
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); }