Possible Duplicate:
C#: Public Fields versus Automatic PropertiesDuplicate? I think not:
This question is not the same as “Why
use properties instead of public
field”. A property with a specified
getter and setter is far different
than a public field. My question was,
is a property WITHOUT a getter and
setter, any different.
With the somewhat recent ability to have empty getters and setters, what is the benefit of using them instead of just declaring a public member variable?
Example:
public string MyProperty
{
get;
set;
}
versus:
public string MyProperty;
One word: inheritance.
Properties are inheritable while fields are not. You can use fields in an inherited class, but not alter their behavior by making them virtual.
Like so:
Edit: Besides the fact of inheritance, the points pointed out in the other answers (like visibility) are also a huge benefit of properties over fields.