Specification:
1. Do not place multiple classes in a source code file.
2. Name the source code file with the names of the public types that are included.
Property:
The key feature of a property is that it provides an API that looks like a field from an angle, but there is no such field in fact.
The auto-implemented properties are encapsulated in fields that do not now require additional code and may require additional validation in the future.
This way, although the declaration of a property changes, the calling code does not need to make any changes.
In the choice between an explicit assignment and a value method and a property, the general coding specification is that the method should represent the action, and the attribute is used to represent the data. Properties are designed to simplify access to simple data. What is expected in the encoding is that the cost of invoking the property should not be much higher than the Access field.
Specification:
To use attributes to simplify access to simple data (for a small amount of computation).
Avoid throwing exceptions from the property's accessor method.
To preserve the original property value when the property throws an exception.
Specification:
Use nouns, noun phrases, or adjectives to clearly attribute.
Consider having a property with the same name as its type.
Avoid naming fields with camel-cased styles.
If useful, append the Is/can/has prefix to the Boolean attribute.
Instead of declaring the instance fields of public or protected, the fields are exposed through properties.
To name attributes in Pascal case style
You prefer to use auto-implemented properties instead of fields.
If there is no additional implementation logic, prioritize the auto-implemented properties instead of writing the full version yourself.
As a good programming habit, you should only use the supported fields of properties within the property implementation, and do not call the fields directly until you have used the attributes. That way, as long as you add code to the property, such as validation code, the entire class can immediately take advantage of the code
Property and method calls are not allowed to be used as ref or out parameter values.
C # Object-oriented programming