title: Why are increment operators possible on properties while ref is not
body: <p>Say you have a class like this</p>
  
  <pre><code>public class Foo
  {
     public int Bar { get; set; } = 42;
  }
  </code></pre>
  
  <p>If you try to pass the property as a <code>ref</code> parameter the compiler issues the error</p>
  
  <blockquote>
    <p>CS0206 A property or indexer may not be passed as an out or ref
    parameter</p>
  </blockquote>
  
  <p>This is understandable since in practice the property in the above example is compiled into <code>get_Bar()</code> and <code>set_Bar()</code> methods. But if you use an increment operator on the property, like</p>
  
  <pre><code>var foo = new Foo();
  foo.Bar++;
  </code></pre>
  
  <p>it works as expected. To achieve this, the compiler needs to produce something like this pseudo code:</p>
  
  <pre><code>var foo = new Foo();
  int tmp = foo.get_Bar();
  tmp++;
  foo.set_Bar(tmp);
  </code></pre>
  
  <p>So in theory the compiler could do a similar thing for <code>ref</code> like:</p>
  
  <pre><code>var foo = new Foo();
  int tmp = foo.get_Bar();
  DoSomething(ref tmp);
  foo.set_Bar(tmp);
  </code></pre>
  
  <p>Is there a technical reason why the compiler doesn't do that or was this just a design decision of the C# team?</p>