Reputation: 4259
Can we implement delegates and events in Interface?
Upvotes: 1
Views: 1590
Reputation: 1500515
You can specify an event in an interface, but you can't declare a delegate (or any other type) - at least not in C#. For instance:
// Valid
public delegate void BarHandler(object sender, EventArgs e);
public interface IFoo
{
event BarHandler Bar;
}
// Invalid
public interface IFoo
{
delegate void BarHandler(object sender, EventArgs e);
event BarHandler Bar;
}
Upvotes: 6