Normally I can call this.GetType(), but I can't access this in a static method. How can we check it?
new StackFrame().GetMethod().DeclaringType
or
MethodBase.GetCurrentMethod().DeclaringType
or
new StackTrace(true).GetFrame(<frame index>).GetMethod() //e.g. <frame index> = 0
Use typeof:
string className = typeof(MyClass).Name;
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