Why should events in C# take (sender, EventArgs)?

前端 未结 10 1288
轻奢々
轻奢々 2020-12-08 18:46

It\'s known that you should declare events that take as parameters (object sender, EventArgs args). Why?

10条回答
  •  猫巷女王i
    2020-12-08 19:30

    Because it's a good pattern for any callback mechanism, regardless of language. You want to know who sent the event (the sender) and data that is pertinent to the event (EventArgs).

提交回复
热议问题