Do event members belong in interfaces?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Do event members belong in interfaces? I have used events in interfaces to
report state changes and they work well. However; I really never see event
members in any of the framework interfaces. So, is there some reason for
this lack of event members in the framework interfaces beside the fact that
they may not be needed? Is it a performance issue or a design issue or maybe
there is not problem with this design?
 
I can't attest to your specific design, but I have used events in
interfaces. I do not see a problem with them if there is a true need for
them. If you want to force all classes that implement the interface to use
those event, then do for it.
 
System.ComponentModel.IComponent has an event declaration: Disposed. There are probably others in the framework that have event
declarations too.

If it's appropriate for your design pattern, there is no problem adding an event field to an Interface declaration.
 
Thanks for your comments. As I said I have used events in interfaces before
and just wanted to make sure there was not some issue I did not know about.
I did have a look at FX Cop and did not have a problem with this either.

Again, thanks.
 
Back
Top