c# 4.5以上通过CallerFilePath获取调用所在类

public void LogHelpers([CallerFilePath] string propertyName = "")
{
this.name = name;
}

原文地址:https://www.cnblogs.com/aaaaq/p/8542479.html