Properties and its Restrictions : Properties : Class C# Examples


C# Examples » Class » Properties »

 

Properties and its Restrictions






A property consists of a name along with get and set accessors.
The accessors are used to get and set the value of a variable.

The general form of a property is shown here:




    
type  propertyName  {
                get  {
                        //  get  accessor  code
                }
                
                set  {
                        //  set  accessor  code
                }
        }
    
   
  
   


A property cannot be passed as a ref or out parameter to a method.
You cannot overload a property.
A property should not alter the state of the underlying variable when the get accessor is called.

(Quote from C# The Complete Reference, Publisher: Osborne/McGraw-Hill, March 8, 2002,
Language: English ISBN-10: 0072134852 ISBN-13: 978-0072134858)



HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Class
» Properties