Why can't I put a delegate in an interface?

前端 未结 7 1022
清歌不尽
清歌不尽 2021-02-01 03:24

Why can\'t I add a delegate to my interface?

7条回答
  •  借酒劲吻你
    2021-02-01 04:15

    this is a delegate TYPE decalaration...

    public delegate returntype MyDelegateType (params)
    

    this cant be declared in an interface as it is a type declaration

    however using the type declaration above you CAN use a delegate instance

    MyDelegateType MyDelegateInstance ( get; set;)
    

    so delegate instances are OK but delegate type declarations aren't (in an interface)

提交回复
热议问题