共用方式為


編譯器錯誤 CS0065

更新:2007 年 11 月

錯誤訊息

'event': 事件屬性必須同時有 add 和 remove 存取子

不是欄位的事件必須同時擁有這兩種存取方法。

下列範例會產生 CS0065:

// CS0065.cs
using System;
public delegate void Eventhandler(object sender, int e);
public class MyClass
{
   public event EventHandler Click   // CS0065,
   {
      // to fix, uncomment the add and remove definitions
      /*
      add
      {
         Click += value;
      }
      remove
      {
         Click -= value;
      }
      */
   }

   public static void Main()
   {
   }
}

請參閱

參考

事件 (C# 程式設計手冊)