I know you can do
this.GetType().FullName
To get
My.Current.Class
But what can I call to get
My.Current.Class.CurrentMethod
The current method name that contains the execution point that is represented by the current stack trace element is provided by the java. lang. StackTraceElement. getMethodName() method.
Method name − Method name is a unique identifier and it is case sensitive. It cannot be same as any other identifier declared in the class. Parameter list − Enclosed between parentheses, the parameters are used to pass and receive data from a method.
Get name of current method in C# This post will discuss how to get the name of the current method being executed in C#. 1. Using StackTraceClass (System.Diagnostics) A stack trace is an ordered collection of one or more stack frames that store debugging and diagnostic information.
This post will discuss how to get the name of the current method being executed in C#. 1. Using StackTraceClass (System.Diagnostics) A stack trace is an ordered collection of one or more stack frames that store debugging and diagnostic information. The following example creates a simple stack trace using the StackTraceinstance.
Getting name of currently executing method is useful for handling exceptions and debugging purposes. Below are different methods to get currently executing method : Using Throwable Stack Trace : Using Throwable Class : In Java, Throwable class is the superclass of all exceptions and errors in java.lang package.
Using Thread Stack Trace : The Thread.getStackTrace () method returns array of stack trace elements. The second element of the returned array of stack trace contains name of method of current thread. Writing code in comment?
Call System.Reflection.MethodBase.GetCurrentMethod().Name
from within the method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With