Export (0) Print
Expand All
Expand Minimize

Compiler Error CS0073

An add or remove accessor must have a body

An add or remove keyword in an event definition must have a body. For more information, see Events (C# Programming Guide).

The following sample generates CS0073:

// CS0073.cs
delegate void del();

class Test
{
   public event del MyEvent
   {
      add;   // CS0073
      // try the following lines instead
      // add
      // {
      //    MyEvent += value;
      // }
      remove
      {
         MyEvent -= value;
      }
      
   }

   public static void Main()
   {
   }
}

Community Additions

ADD
Show:
© 2014 Microsoft