Is there a way to do this:
var methodToDoStuffTo = typeof (FancyClass).GetMethod("MethodName").Name;
Without relaying on the string "MethodName"
?
What I want is something like this:
var methodToDoStuffTo = typeof (FancyClass).GetMethod(FancyClass.MethodName).Name;
So I can be sure that there is no unexpected error when I rename my method MethodName
.
For reasons I can't simple update my enviroment to c# 6, so no nameof()
.
I try and give a reason why I'am doing this:
I (have to) use one Authorization Attribute
on several different Methods.
Depending on from which method the Attribute was 'called', the code has to do slitly different stuff.
That's why I can't / don't want to use differnet Attributes for each Method.