Let me try to give a little example.
class Session (
public delegate string CleanBody();
public static void Execute(string name, string q, CleanBody body) ...
can be used like:
Session.Execute("foo", "bar", delegate() { string x="beep"; /* whatever*/ return x; });
But what if I need to run is via MethodInfo.Invoke -- as in different dll no type dependencies either way. Like:
Type type = Type.GetType("Bla.Session, FooSessionDll", true);
MethodInfo methodInfo = type.GetMethod("Execute");
Object [] args = { "foo", "bar", delegate() // Doesn't compile, now that ?
{
string x="beep"; /* whatever*/ return x;
}
methodInfo.Invoke("Trial Execution :-)", args);
Whatever trick/cast would be applied it would have to be such that it still arrives at Execute as a genuine delegate. Actual delegate(s) may have more complex signatures etc. etc.