I want to have a class that will execute any external method, like this:
class CrazyClass
{
//other stuff
public AnyReturnType Execute(AnyKindOfMethod M
You can do this a different way by Func and closures:
public T Execute(Func method)
{
// stuff
return method();
}
The caller can then use closures to implement it:
var result = yourClassInstance.Execute(() => SomeMethod(arg1, arg2, arg3));
The advantage here is that you allow the compiler to do the hard work for you, and the method calls and return value are all type safe, provide intellisense, etc.