title: For i = 0, why is (i += i++) equal to 0?
body: <p>Take the following code (usable as a Console Application):</p>
  
  <pre><code>static void Main(string[] args)
  {
      int i = 0;
      i += i++;
      Console.WriteLine(i);
      Console.ReadLine();
  }
  </code></pre>
  
  <p>The result of <code>i</code> is 0. I expected 2 (as some of my colleagues did). Probably the compiler creates some sort of structure that results in <code>i</code> being zero.</p>
  
  <p>The reason I expected 2 is that, in my line of thought, the right hand statement would be evaluated first, incrementing i with 1. Than it is added to i. Since i is already 1, it is adding 1 to 1. So 1 + 1 = 2. Obviously this is not what's happening.</p>
  
  <p>Can you explain what the compiler does or what happens at runtime? Why is the result zero?</p>
  
  <p><em>Some-sort-of-disclaimer: I'm absolutely aware you won't (and probably shouldn't) use this code. I know I never will. Nevertheless, I find it is interesting to know why it acts in such a way and what is happening exactly.</em></p>