Accessibilities of get and set

The get and set accessors used to define the logic for the property can have different accessibilities.


class Rectangle{
   private int width;
   
   public int Width{
      public get{
         return width;
      }
      protected set{
         width = value;
      }
   }
}

The property should have more accessible modifiers than the get or set accessor.

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.