In a C# event handler, why must the “sender” parameter be an object?

后端 未结 12 772
半阙折子戏
半阙折子戏 2020-12-02 08:19

According to Microsoft event naming guidelines, the sender parameter in a C# event handler \"is always of type object, even if it is possible to use a

12条回答
  •  南方客
    南方客 (楼主)
    2020-12-02 09:02

    It's because you can never be sure who fired the event. There is no way to restrict which types are allowed to fire a certain event.

提交回复
热议问题