1. A Property encapsulates a field member of the same class, so that the field member is not freely accessible outside the class and the required validation/restriction can be put over it.
2. A property is made of two blocks i.e. Get and Set. Get block is invoked when the property is used on RHS and Set block is invoked when the property is used on LHS.
3. A property procedure doesn’t hold any data by itself instead it depends on some private field member of the class.
4. A Set block can validate the “Value” before it is assigned to the field member of the class being encapsulated by the property. Similarly the field member can be validated before its value is returned in the Get block.
5. Using a property the field member can be restricted with either “ReadOnly” or “WriteOnly” access.
6. A class which has all its field members as Private and if required restricted access to these members is given using Public Properties is called “Fully Encapsulated Class”.
Comments
Post a Comment