How do static events compare to non-static events in C#?

后端 未结 5 671
误落风尘
误落风尘 2020-12-31 05:47

I just realized static events exist - and I\'m curious how people use them. I wonder how the relative comparison holds up to static vs. instance methods. For instance, a s

5条回答
  •  天涯浪人
    2020-12-31 06:30

    Static members are not "global," they are simply members of the class, not of class instances. This is as true for events as it is for methods, properties, fields, etc.

    I can't give an example for using a static event, because I generally don't find static members to be useful in most cases. (They tend to hint at anti-patterns, like Singleton.)

提交回复
热议问题