get calling method
Published: 14. January 2009 | Updated: 14. January 2009License: Microsoft Public License (MS-PL)
Categories: Debug, Framework » Reflection
Tags: C# Debug Reflection
Import namespaces
using System.Diagnostics; using System.Reflection;
Code
StackTrace stackTrace = new StackTrace(); StackFrame stackFrame = stackTrace.GetFrame(1); MethodBase callingMethod = stackFrame.GetMethod(); Console.WriteLine("{0}: {1}", callingMethod.DeclaringType, callingMethod.Name);
| Send us feedback about this snippet » |





