Friday, August 17, 2007

Getting current / calling method info (C#)

Getting current method:
System.Reflection.MethodBase.GetCurrentMethod()

Getting calling method:
System.Diagnostics.StackTrace st =
new System.Diagnostics.StackTrace(false);


System.Diagnostics.StackFrame sf =
st.GetFrame(1); // previous method

return sf.GetMethod();

No comments: