I have several methods all with the same parameter types and return values but different names and blocks. I want to pass the name of the method to run to another method tha
You should use a Func
delegate, that represents a function taking a string
argument and returning an int
value:
public bool RunTheMethod(Func myMethod)
{
// Do stuff
myMethod.Invoke("My String");
// Do stuff
return true;
}
Then invoke it this way:
public bool Test()
{
return RunTheMethod(Method1);
}