We’re used to requesting the name of the current method by doing something like this:
Type thisClassInstanceType = this.GetType();
Where this doesn’t work, is within a static method, where there is no ‘this’ instance.
In such cases, do the following:
Type thisStaticMethodClassType =
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType;
If you are interested in the method itself, rather than the class that wraps it, its even easier:
string thisMethodName =
System.Reflection.MethodBase.GetCurrentMethod().Name;
Further reading: