title: About Encapsulation : properties
body: <p>Case I :</p>
  
  <pre><code>class example
  {
     private int roll;
     public int Roll
     {
         get { 
             return roll; 
         }
         set{
             if (value &gt; 0)
             { roll = value; }   
         }
     }
     //public example()
     //{
     //    roll = 500;
     //}
  
  }
  
  class practice_4
  {
      static void Main(string[] args)
      {
          example ABC = new example();
          Console.WriteLine(ABC.Roll = -1);
          Console.ReadLine();
  
      }
  }
  </code></pre>
  
  <p>Output : -1</p>
  
  <p>I have set a business logic that does not contain any illegal value and gives me by default value "0"..</p>
  
  <p>Case II:</p>
  
  <pre><code>class example
  {
     private byte roll;
     public byte Roll
     {
         get { 
             return roll; 
         }
         set{
             if (value &gt; 0)
             { roll = value; }   
         }
     }
     //public example()
     //{
     //    roll = 500;
     //}
  
  }
  
  class practice_4
  {
      static void Main(string[] args)
      {
          example ABC = new example();
          Console.WriteLine(ABC.Roll = -1);
          Console.ReadLine();
  
      }
  }
  </code></pre>
  
  <p>Above code is displaying compile time error as I just change valuetype Int to byte </p>
  
  <p>error: constant value -1 cannot converted to byte ...</p>
  
  <p>what Console.WriteLine Method really do ?</p>