获知哪个函数调用了本函数及它的类名

获知哪个函数调用了本函数及它的类名

StackTrace st = new StackTrace();
StackFrame callerFrame = st.GetFrame(2);
string callerInfo = callerFrame.GetMethod().DeclaringType.Name + "." + callerFrame.GetMethod().Name + "()";

原文地址:https://www.cnblogs.com/swordzj/p/3440146.html