title: What is the difference between property and public field
body: <p>I have read msdn article about properties. They show that example of property:</p>
  
  <pre><code>// Declare a Name property of type string:
      public string Name
      {
          get 
          {
             return myName; 
          }
          set 
          {
             myName = value; 
          }
      }
  </code></pre>
  
  <p>Then they say: </p>
  
  <blockquote>
    <p>Once the properties are declared, they can be used as if they were
    fields of the class.</p>
  </blockquote>
  
  <p>What would be the difference if they just left:</p>
  
  <pre><code>public string Name;
  </code></pre>
  
  <p>If I had a field: <code>private string name</code> and wanted to have only getter? Should I declare</p>
  
  <p><code>public string GetName(){return name;}</code> or should use those properties somehow?</p>
  
  <hr>
  
  <p>Could somebody tell me what is wrong with that example:</p>
  
  <pre><code> private int age;
   public void setAge(int age){
     if(age &lt; 100) 
     this.age = age;
  }
  </code></pre>