Reputation: 86135
I know the class implementing an interface must implement all its method. But what does event inside the interface mean?
Upvotes: 2
Views: 602
Reputation: 136124
It means anything implementing that interface must raise that event. Pretty much the same as a Method or Property within an interface.
Upvotes: 0
Reputation: 1501656
It means that the type must implement the event - so that clients can subscribe to those events.
Think of events as pairs of methods (add/remove) just as properties have get/set. Just as you can have properties in interfaces, you can have events: the implementation has to provide the appropriate add/remove methods and the metadata to tie them to the event. In C# this can be done using field-like events:
public event EventHandler EventFromInterface;
or with explicit add/remove methods:
public event EventHandler EventFromInterface
{
add { ... }
remove { ... }
}
Upvotes: 8