Can Events be declared as Static, if yes how and why

后端 未结 4 1869
时光说笑
时光说笑 2020-12-03 04:16

I want to know can we declare the events as static if yes why and application of such declaration.

Sample please as seeing is believing

4条回答
  •  攒了一身酷
    2020-12-03 04:44

    Yes, you can. See, for example, Application.ApplicationExit. Note, however, the warnings on that page about memory leaks when attaching to static events; that applies to all static events.

    There's nothing magical about when you use them: when you need to provide an event for a static class or an event that deals exclusively with static data and it makes sense to implement it this way.

提交回复
热议问题