title: C# CS0079 Event Handling Compile Errors
body: <p>I can't compile the following code.  </p>
  
  <blockquote>
    <p><em>Compile error CS0079 : The event 'CustomEvent' can only appear on the left hand side of += or -=</em></p>
  </blockquote>
  
  <pre><code>if (CustomEvent != null)   //CS0079
      CustomEvent(null, null);  //CS0079
  </code></pre>
  
  <p>How can I make this work?</p>
  
  <p>My implementation is like this:</p>
  
  <pre><code>public delegate void EventHandler(object sender, EventArgs e);  
  public static event EventHandler CustomEvent
  {
      add    { CustomEvent += value; }
      remove { CustomEvent -= value; }
   }
  private static void Func()
  {
      if (CustomEvent != null)      //CS0079
          CustomEvent(null, null);  //CS0079
  }
  </code></pre>