当没有订阅者时,为什么委托为空而不是空列表?

Mar*_*lin 8 .net c# events delegates

有人可以解释为什么.Net框架团队决定没有订阅者的委托应该是null而不是具有空InvocationList的对象吗?我想知道导致这一决定的理由.

void DoSomething()
{
    EventHandler handler = SomeEvent;
    if(handler != null)                   //why is this null-check necessary?
    {
        handler(this, EventArgs.Empty);
    }
}
Run Code Online (Sandbox Code Playgroud)

谢谢

SLa*_*aks 8

在CLR级别,委托字段和事件字段是常规字段.

就像string MyField默认为null,而不是"",所以也Action MyField默认null,而不是一个空的Action实例.