I have a method. I want to check a condition and
if result of my condition is true throw new exception.
I need to name of method for message exception. For example :
public void MyMethod(Notifier not)
{
if(not.HasValue())
throw new Exception("MyMethod_name : " + not.Value);
}
How get name of method in the method?
This approach avoids the stack issues:
[But note that there may occasionally be unexpected results: for example, small methods or properties are often inlined in release builds, in which case the result will be the caller’s method name instead.]