Auto-Implemented Properties :
Auto-implemented properties make property-declaration more concise when no additional logic is required in the property accessors.
When you declare a property as shown in the following example, the compiler creates a private, anonymous backing field can only be accessed through the property’s get and set accessors.
The following example shows a simple class that has some auto-implemented properties:
Attributes are not permitted on auto-implemented properties. If you must use an attribute on the backing field of a property, just create a regular property.
Share your thoughts with me !!!
- Rangoli
Auto-implemented properties make property-declaration more concise when no additional logic is required in the property accessors.
When you declare a property as shown in the following example, the compiler creates a private, anonymous backing field can only be accessed through the property’s get and set accessors.
The following example shows a simple class that has some auto-implemented properties:
Auto-implemented properties must declare both a get and a set accessor. To create a readonly auto-implemented property, give it a private set accessor.class Emplyee
{
public int ID { get; private set; } // read-only
public string Name { get; private set; } // read-only
public string Destination { get; set; }
}
Attributes are not permitted on auto-implemented properties. If you must use an attribute on the backing field of a property, just create a regular property.
Share your thoughts with me !!!
- Rangoli