title: The C# events implementation (articles vs reflector)
body: <p>public class EventsType
      {
          public event EventHandler> NewEvent;</p>
  
  <pre><code>    public void SmthHappened(string data)
      {
          MyEventArgs&lt;Object&gt; eventArgs = new MyEventArgs&lt;Object&gt;(data);
          OnNewEvent(eventArgs);
      }
  
      private void OnNewEvent(MyEventArgs&lt;Object&gt; eventArgs)
      {
          EventHandler&lt;MyEventArgs&lt;Object&gt;&gt; tempEvent = NewEvent;
  
          if (tempEvent != null)
          {                
              tempEvent(this, eventArgs);
          }
      }
  }
  </code></pre>
  
  <p>I expected that the C# compiler will translate the NewEvent like this:</p>
  
  <pre><code>private EventHandler&lt;MyEventArgs&lt;object&gt;&gt; _newEvent;
  
  public event EventHandler&lt;MyEventArgs&lt;object&gt;&gt; NewEvent
  {
      [MethodImpl(MethodImplOptions.Synchronized)]
      add
      {
      _newEvent = (EventHandler&lt;MyEventArgs&lt;object&gt;&gt;)Delegate.Combine(_newEvent, value);
      }
      [MethodImpl(MethodImplOptions.Synchronized)]
      remove
      {
      _newEvent = (EventHandler&lt;MyEventArgs&lt;object&gt;&gt;)Delegate.Remove(_newEvent, value);
      }
  }
  </code></pre>
  
  <p>, but the Reflector says that it is implemented this way:</p>
  
  <pre><code>public event EventHandler&lt;MyEventArgs&lt;object&gt;&gt; NewEvent
  {
      add
      {
          EventHandler&lt;MyEventArgs&lt;object&gt;&gt; handler2;
          EventHandler&lt;MyEventArgs&lt;object&gt;&gt; newEvent = this.NewEvent;
          do
          {
              handler2 = newEvent;
              EventHandler&lt;MyEventArgs&lt;object&gt;&gt; handler3 = (EventHandler&lt;MyEventArgs&lt;object&gt;&gt;) Delegate.Combine(handler2, value);
              newEvent = Interlocked.CompareExchange&lt;EventHandler&lt;MyEventArgs&lt;object&gt;&gt;&gt;(ref this.NewEvent, handler3, handler2);
          }
          while (newEvent != handler2);
      }
      remove
      {
          EventHandler&lt;MyEventArgs&lt;object&gt;&gt; handler2;
          EventHandler&lt;MyEventArgs&lt;object&gt;&gt; newEvent = this.NewEvent;
          do
          {
              handler2 = newEvent;
              EventHandler&lt;MyEventArgs&lt;object&gt;&gt; handler3 = (EventHandler&lt;MyEventArgs&lt;object&gt;&gt;) Delegate.Remove(handler2, value);
              newEvent = Interlocked.CompareExchange&lt;EventHandler&lt;MyEventArgs&lt;object&gt;&gt;&gt;(ref this.NewEvent, handler3, handler2);
          }
          while (newEvent != handler2);
      }
  }
  </code></pre>
  
  <p>Please, smb explain me why is it so?  </p>