title: Properties in c# in Unity (Unity5) - can you avoid the backing variable
body: <p>With Unity5 (it's hard to know exactly what version of c#/Mono/.Net is being used), we do properties exactly like this:</p>
  
  <pre><code>private int _distance;
  public int Distance
      {
      private set
          {
          _distance = value;
          controls.Blahblah(_distance);
          }
      get
          {
          Debug.Log("hah!);
          return _distance;
          }
      }
  </code></pre>
  
  <p>But consider the new <strong>"automatic properties"</strong> in c#, which seem to be like</p>
  
  <pre><code> public int Distance {get; set;}   // ?
  </code></pre>
  
  <p>but I don't know how to "do something" in the getter/setter ??</p>
  
  <p>Or in other words, is there a way to auto generate the backing variable (as well as the convenience -- to keep it private) when "manually" making a Property?</p>
  
  <p>To repeat since this was marked as a duplicate, how can I "do stuff" in the automatic Property idiom during the getter/setter ...</p>
  
  <p>... or conversely ...</p>
  
  <p>how to hide, get rid of, or automatically supply the backer if you write your own "manual" properties?</p>
  
  <p>Note that of course you or another programmer can accidentally touch the _underscore backing variable: <strong>is there any way at all to avoid that??</strong></p>