Error del compilador CS0072
Actualización: noviembre 2007
Mensaje de error
'evento': no se puede reemplazar; 'método' no es un evento
'event' : cannot override; 'method' is not an event
Un evento sólo puede reemplazar a otro evento. Para obtener más información, vea Eventos (Guía de programación de C#).
El código siguiente genera el error CS0072:
// CS0072.cs
delegate void MyDelegate();
class Test1
{
public virtual event MyDelegate MyEvent;
public virtual void VMeth()
{
}
public void FireAway()
{
if (MyEvent != null)
MyEvent();
}
}
class Test2 : Test1
{
public override event MyDelegate VMeth // CS0072
// uncomment the following lines to resolve
// public override event MyDelegate MyEvent
{
add
{
VMeth += value;
// MyEvent += value;
}
remove
{
VMeth -= value;
// MyEvent -= value;
}
}
public static void Main()
{
}
}