Static events

Events modified with the static keyword behave much like static fields, in that while each copy of a class contains separate copies of all fields, there can only be one copy of a static member at any given time. All objects of the class share static events. When they are referenced, they must be referenced by the class name and not the object name, as shown in the following:

public class Counter {

public static event EvenNumberHandler OnEvenNumber; // ...

Counter.OnEvenNumber += new


As you can see, you must reference the static event OnEvenNumber by specifying the class name and the object name.

0 0

Post a comment