编译器错误 CS0066

更新:2007 年 11 月

错误消息

“event”:事件必须是委托类型

event 关键字需要委托类型。有关更多信息,请参见事件(C# 编程指南)委托(C# 编程指南)

下面的示例生成 CS0066:

// CS0066.cs
using System;

public class EventHandler
{
}

// to fix the error, remove the event declaration and the
// EventHandler class declaration, and uncomment the following line
// public delegate void EventHandler();

public class a
{
   public event EventHandler Click;   // CS0066

   private void TestMethod()
   {
      if (Click != null)
         Click();
   }

   public static void Main()
   {
   }
}