title: Learning about Auto-Implemented Properties
body: <p>I have the simple class using auto-implemented properies:  </p>
  
  <pre><code>Public Class foo
  {
      public foo() { }  
  
      public string BarName {get; set;}
  }
  </code></pre>
  
  <p>I obviously use the variable BarName throughout my class and now need to add logic when the property value is set (it must be all upper case, go figure).  Does this mean that I need to now create a private variable for BarName , e.g. _BarName,  and change the current BarName variable used throughout my class to _BarName?   </p>
  
  <pre><code>Public Class foo
  {
      public foo() {}  
  
      private string _BarName = "";
      public string BarName 
      { 
          get {return _BarName;}
          set {_BarName = Value.ToString().ToUpper();}
      }
  }
  </code></pre>
  
  <p>I am trying to make sure I understand the implications of using auto-implemented properties, and what it will entail down the road when/if I need to change something.  I am assuming that the refactoring, as shown above, is not a <a href="http://blogs.msdn.com/abhinaba/archive/2006/04/11/572694.aspx" rel="nofollow noreferrer">breaking</a> change because the property is basically staying the same; it just took a little work inside the class to keep it that way and add the needed logic.   </p>
  
  <p>Another example, which may be more meaningful is that I need to call some method when a setter or getter is used; more then changing the value.  </p>
  
  <p>This seems a fair trade off the the lines and lines of code to setup properties. </p>