I understand the many benefits of providing an interface to access the members of a class indirectly. My question is: isn\'t that already something you can accomplish in jus
Maybe a minor point, but with getters /setters I find it annoying that when I'm cycling through them in an IDE with 'intellisense' there's a massive block of 'getters' next to each other and another block of 'setters'. I find it more difficult to find what I'm looking.
Jon Skeet has an excellent overview on his C# article blog about why properties matter. In it he explains why properties should be used over exposing public fields.
As for why to use properties instead of getter/setter methods, I would suggest the following thoughts:
A.x = B.y = C.z
They allow the user of the type to have a simplified syntax, and allow you to create read-only and write-only fields. Thus me.SetAge(34); age = me.GetAge(); becomes me.age = 34; age = me.age;
Aside from the semantic correctness of using properties for a value that describes a property of an object, you can't argue with this:
obj.SetValue(obj.GetValue() + 1);
vs
obj.Value++;
At least for DataBinding
UI-related development becomes way more complex without it.
I believe XML Serialization only reads/writes public properties, so your get and set methods would be ignored.
Also, if you have a generic list of objects, you can assign that to a DataGridView.DataSource and you'll get a column for each of your properties. That may be what @LPalmer was referring to.