更新:2007 年 11 月
错误消息
“event”:接口中的事件不能有初始值设定项
接口中的事件不能有初始值设定项。有关更多信息,请参见接口(C# 编程指南)。
下面的示例生成 CS0068:
// CS0068.cs
delegate void MyDelegate();
interface I
{
event MyDelegate d = new MyDelegate(M.f); // CS0068
// try the following line instead
// event MyDelegate d2;
}
class M
{
event MyDelegate d = new MyDelegate(M.f);
public static void f()
{
}
public static void Main()
{
}
}