anonymous delegate <> System.Delegate
結局は
eventInfo.AddEventHandler(control, new EventHandler(
delegate(object sender, EventArgs e)
{
action.Run();
})
);
というコードが、
eventInfo.AddEventHandler(control,
delegate(object sender, EventArgs e)
{
action.Run();
});
と書けないのが、つまり匿名デリゲートはSystem.Delegateと互換性が無いのが自由度を低くしていると思う。
あ、もちろん.NETの匿名デリゲートがクロージャやブロックではなく、コンパイラが自動的に生成するこんな感じの
private sealed class DisplayClass2
{
public DisplayClass2(){}
public void Add(object sender, EventArgs args)
{
this.action.Run();
}
public IAction action;
}
インナークラスのシンタクスシュガーであることは承知の上。