編譯器錯誤 CS0066
更新:2007 年 11 月
錯誤訊息
'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()
{
}
}