title: When does ++ not produce the same results as +1?
body: <p>The following two C# code snippets produce different results (assuming the variable level is used both before and after the recursive call). Why?</p>
  
  <pre><code>public DoStuff(int level)
  {
    // ...
    DoStuff(level++);
    // ...
  }
  </code></pre>
  
  <p>,</p>
  
  <pre><code>public DoStuff(int level)
  {
    // ...
    DoStuff(level+1);
    // ...
  }
  </code></pre>
  
  <p>After reading some of the responses below I thought it would be worthwhile posting the stack traces for level++, ++level and level+1 to highlight how deceiving this problem is.</p>
  
  <p>I've simplified them for this post. The recursive call sequence starts with DoStuff(1). </p>
  
  <p>// level++</p>
  
  <pre><code>DoStuff(int level = 1)
  DoStuff(int level = 2)
  DoStuff(int level = 2)
  DoStuff(int level = 2)
  </code></pre>
  
  <p>// ++level</p>
  
  <pre><code>DoStuff(int level = 4)
  DoStuff(int level = 4)
  DoStuff(int level = 3)
  DoStuff(int level = 2)
  </code></pre>
  
  <p>// level+1</p>
  
  <pre><code>DoStuff(int level = 4)
  DoStuff(int level = 3)
  DoStuff(int level = 2)
  DoStuff(int level = 1)
  </code></pre>