title: Checking if the handler != null vs Checking if the event != null in C#
body: <p>I have seen various coding styles to fire events in C#. 
  The first style consisting of the following:</p>
  
  <p>-an event handler</p>
  
  <pre><code>    public delegate void NumberReachedEventHandler(object sender, 
      NumberReachedEventArgs e);
  </code></pre>
  
  <p>-an event</p>
  
  <pre><code>    public event NumberReachedEventHandler NumberReached;
  </code></pre>
  
  <p>-and the method to fire the event</p>
  
  <pre><code>    protected virtual void OnNumberReached(NumberReachedEventArgs e)
      {
          if(NumberReached != null)
          {
              NumberReached(this, e);
          }
      }
  </code></pre>
  
  <p>The second style however, has a different method to fire the event:</p>
  
  <pre><code>    protected virtual void OnNumberReached(NumberReachedEventArgs e)
      {
          NumberReachedEventHandler handler = NumberReached;
          if(handler != null)
          {
              handler(this, e);
          }
      }
  </code></pre>
  
  <p>To me, it appears that one style checks if the "event" is null and the second style checks if the delegate is null. However, my understanding is that an event is just an instance of a delegate, so I am wondering if there are any advantages to either way of writing the code. If so, please explain. Thanks in advance. </p>