Error del compilador CS0068

Actualización: noviembre 2007

Mensaje de error

'evento': el evento de una interfaz no puede tener un inicializador
'event': event in interface cannot have initializer

El evento de una interfaz no puede tener un inicializador. Para obtener más información, vea Interfaces (Guía de programación de C#).

El código siguiente genera el error 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()
   {
   }
}