In C#, you can get the caller of a function using the Reflection API or the StackTrace class.
main.cs147 chars8 linesThis will return the method that called MyFunction, and you can get the name of the method using caller.Name.
main.cs209 chars9 linesThis will return the second method in the call stack (the first method is MyFunction), and you can get its name using callerFrame.GetMethod().Name.
Note that getting caller information like this can be useful for debugging purposes, but it can also impact performance and should be used sparingly. In C# 5.0 and later, you can use the CallerInfo attributes to get function caller information easily without the need for Reflection or StackTrace.
gistlibby LogSnag