您可以在接口中指定事件,但不能声明委托(或任何其他类型) - 至少不能在C#中声明.例如:
// 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;
}
Run Code Online (Sandbox Code Playgroud)