Perhaps the easiest way would be to provide an overload FunctionWithStringParameter
which can take a delegate as a parameter.
The overload could be as simple as:
void FunctionWithStringParameter(Action d)
{
FunctionWithStringParameter(d.Method.Name);
}
And call it like this:
FunctionWithStringParameter(MyMethodName);
To accept methods with different signatures, you'd have to either provide many different overloads, or accept Delegate
as a parameter, like this:
void FunctionWithStringParameter(Delegate d)
{
FunctionWithStringParameter(d.Method.Name);
}
Unfortunately, if you do this, you would have to call it by specifying a delegate type:
FunctionWithStringParameter((Action)MyMethodName);