Fields are custom variables or constants in the class. They are used to record related information and attributes of the class. They are usually no different from external definitions, that is, they need to add public modifiers;
Attribute is also one of the concepts in the class, that is, a function method for external access to internal private fields,
It is generally divided into custom attributes:
Use the get and set accessors to assign values to fields.
Default definition,
Attribute fields are generated by default if only get and set are declared and not specified.
Note that read-only and write-only attributes can be implemented by defining only one of get and set attributes;
Attribute can also be set to restrict access to fields. For example, you can add judgment in set, and other values can be returned in get return.
Static fields can be implemented through static attributes, which can be directly used in the class, and can be accessed outside the class by class name. Attribute (provided that the attribute must be public );
C # attributes and fields in the class