title: How get set property works in C#?
body: <p>I am new to C# and am exploring the very basic of C# <strong>get</strong> and <strong>set</strong> properties. What I have found is, The get set accessor or modifier mostly used for storing and retrieving value from the private field. </p>
  
  <p>In this case, What is the problem with using public fields? </p>
  
  <p>Another thing, I have written some conditions inside <strong>get</strong> and <strong>set</strong>. The code is</p>
  
  <pre><code>public int Number
      {
          get
          {
              if(Number&gt;10)return 10;
              else
              {
                  return Number;
              }
          }
          set
          {
              if (value &gt; 10)
              {
                  Number = 10;
              }
              else
              {
                  Number = value;
              }                   
          }
      }
  </code></pre>
  
  <p>Whats the problem here? </p>
  
  <p>And another interesting thing is, in VS, the recursive sign appears where I check the conditions.Can someone explain it, please? </p>
  
  <p><a href="https://i.stack.imgur.com/n1izd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/n1izd.png" alt="enter image description here"></a></p>
  
  <p>I am new to C# and wants to learn from the basic.
  Thanks in advance. </p>