An attribute is an abstraction of an entity feature in the real world that provides access to the nature of a class or object. For example, a user's name, the size of a file, and the title of a window can all be attributes. The property of a class describes the state information, and the value of the property in an instance of the class represents the state value of the object.
The attributes in C # more fully embody the encapsulation of the object: not manipulating the data content of the class directly, but accessing it through the accessor. It uses both get and set to read and write the values of properties, which in C + + is a task that requires the programmer to do it manually.
12.2.1 the C # attribute declaration
The properties of C # are declared in the following manner:
Attributes Proterty-modifiers type Member-name {accessor-declarations}
The modifiers for the attribute property-modifiers are:
New
Public
Protected
Internal
Private
Static
Virtual
Sealed
Override
Abstract
The static,virtual,override and abstract modifiers cannot be used at the same time in the above modifiers.
The access declaration accessor-declaration of a property must be enclosed in a pair of "{" and "}" braces, giving instructions for reading and writing the value of the property.
Although the syntax of a property is similar to that of a field, it cannot be used as a variable, nor can it be passed as a reference parameter or an output parameter.