Properties are members of a class, structure, or interface generally called as a named member. The intended behaviors of properties are similar to fields with the difference being that the implementation of properties is possible with the use of accessors.
Properties are extensions to fields. The accessors get and set helps retrieve and assign value to property.
Here is the typical property (also called property with auto-property syntax) of a class:
public int Number { get; set; }
For auto property, compiler generates the backup field, which is nothing but a storage field. So, the preceding property would be shown as follows, with a backup field:
private int _number;
public int Number
{
get { return _number; }
set { _number = value; }
}
The preceding property with an expression body looks like this:
private int _number;
public int Number
{
get => _number;
...