CSharp - Property get and set accessibility


The get and set accessors can have different access levels.

You can have a public property with an internal or private access modifier on the setter:

class Test
    private decimal x;
    public decimal X
         get         { return x;  }
         private set { x = Math.Round (value, 2); }

For getter it has permissive access, the setter is less accessible.

Related Topics