다음을 통해 공유


컴파일러 오류 CS0072

업데이트: 2007년 11월

오류 메시지

'event' : 재정의할 수 없습니다. 'method'은(는) 이벤트가 아닙니다.
'event' : cannot override; 'method' is not an event

event는 다른 이벤트만 재정의할 수 있습니다. 자세한 내용은 이벤트(C# 프로그래밍 가이드)를 참조하십시오.

다음 샘플에서는 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()
   {
   }
}