Declaring an event in an interface

  • Thread starter Thread starter Brad
  • Start date Start date
B

Brad

I'm using events to handle asynchronous notification upwards and interfaces
across all class boundaries. I'm not sure of how to declare a delegate and
its associated event through the interface. I need to be able to declare
this information in the interface so that the caller can register for the
event. Am I missing something simple?

TIA

Brad
 
Brad,

You can declare the event in the interface, but C# does not allow you
to declare types in an interface so you'll have to declare the delegate
somewhere else.

public delegate void MyEventHandler();

public interface IMyInterface
{
event MyEventHandler MyEvent;
}

Brian
 
Hi,

I think you are :)

this is a valid declaration :

public interface A
{
event EventHandler ev;
}
 
Back
Top