I have a weird situation where I need to get the Name of the delegate as a string. I have a generic method that looks like this.
private T Get<T>(T task, Action<T> method) where T : class
{
string methodName = method.Method.Name //Should return Bark
}
and I am calling it like this
private void MakeDogBark()
{
dog = Get(dog, x=>x.Bark());
}
But instead of seeing "Bark" I see this "<MakeDogBark>b__19"
. So it looks like it is giving me the method name that made the initial call instead of the name of the delegate.
Anyone know how to do this?