The property keyword introduces the declaration of a property and can appear in a class, interface, or value type. A property can have a getter function (read only), a setter function (write only), or both (read-write).
A property name cannot match the name of the managed class containing it. The return type of the getter function must match the type of the last parameter of a corresponding setter function.
To client code, a property has the appearance of an ordinary data member, and can be written to or read from using the same syntax as a data member.
The get and set methods need not agree on the virtual modifier.
The accessibility of the get and set method can differ.
The definition of a property method can appear outside the class body similar to an ordinary method.
The get and the set method for a property shall agree on the static modifier.
A property is scalar if its get and set methods fit the following description:
The get method has no parameters, and has return type T.
The set method has a single parameter of type T, and void return type.
There shall be only one scalar property declared in a single scope with the same identifier. Scalar properties cannot be overloaded.
When a property data member is declared, the compiler will inject a data member, sometimes called the "backing store", in the class. However, the name of the data member will be of a form, such that, you cannot reference the member in the source as if it were an actual data member of the containing class. Use ildasm.exe to view the metadata for your type and see the compiler generated name for the property's backing store.
Different accessibility is allowed for the accessor methods in a property block. That is, the set method can be public and the get method can be private. However, it is an error for an accessor method to have a less restrictive accessibility than what is on the declaration of the property itself.
property is a context-sensitive keyword. See Context-Sensitive Keywords for more information.
For more information about properties, see
The following example shows the declaration and use of a property data member and a property block. It also shows that a property accessor can be defined out of class.