title: Using Events in Interfaces
body: <p>I'm implementing a menu system that uses a composite design pattern. I have the following MenuElement interface:</p>
  
  <pre><code>public interface MenuElement
  {
      void AddMenuElement( MenuElement menuToAdd );
      void RemoveMenuElement( MenuElement menuToRemove );
      MenuElement GetMenuElement( int index );
      void Activate();
  }
  </code></pre>
  
  <p>I was thinking of including an "OnActivate" event in this interface so that MenuItems that implement this interface can trigger functions when activated. I tried implementing it like this:</p>
  
  <pre><code>public interface MenuElement
  {
      public delegate void MenuEvent();
      event MenuEvent onActivate;
  
      void AddMenuElement( MenuElement menuToAdd );
      void RemoveMenuElement( MenuElement menuToRemove );
      MenuElement GetMenuElement( int index );
      void Activate();
  }
  </code></pre>
  
  <p>However, the compiler won't let me declare a delegate inside an interface. I'm aware of a C# event type called EventHandler but unlike my desired MenuEvent, it requires both object and EventArgs parameters. I've also considered moving my event and delegate over to MenuItem instead, but I'm still curious if it is possible to have an interface include a custom event.</p>
  
  <p>Is this possible? Or would I have to use C#'s EventHandler class in this situation?  </p>