Why are all Delegate types incompatible with each other?

后端 未结 3 1629
迷失自我
迷失自我 2021-02-13 14:02

In C# all delegate types are incompatible with one another, even if they have the same signature. As an example:

delegate void D1();
delegate void D2();

D1 d1          


        
3条回答
  •  孤街浪徒
    2021-02-13 14:51

    Delegate is nothing but just another type. They are incompatible for the same reason class A {} and class B {} would be incompatible.

    delegate void D1();
    

    Will approximately compile to something like:

    class D1 : MulticastDelegate { .... } 
    

提交回复
热议问题