private void Method1()
{
//Do something
Log("Something","Method1");
}
private void Method2()
{
//Do something
Log("Something","Method2");
}
private void Log(string message, string method)
{
//Write to a log file
Trace.TraceInformation(message + "happened at " + method);
}
我有几个类似于上面的Method1和Method2的方法,我希望能够以某种方式将方法名称作为参数传递,而不是手动编辑代码。
这是否可能?