Till now, I was under the impression that Properties
& Methods
are two different things in C#. But then I did something like below.
Yes, the compiler generates a pair of get and set methods for a property, plus a private backing field for an auto-implemented property.
public int Age {get; set;}
becomes the equivalent of:
private int k__BackingField;
public int get_Age()
{
return k__BackingField;
}
public void set_Age(int age)
{
k__BackingField = age;
}
Code that accesses your property will be compiled to call one of these two methods. This is exactly one of the reasons why changing a public field to be a public property is a breaking change.
See Jon Skeet's Why Properties Matter.