Just for encapsulation principle. For hiding concrete implementation, and plus, you have an opportunity (in this case) to add additional code inside get/set.
If you don't need additional code, you can use just
public string Name{get; set;}
or use fields, as you would like. But using properties is a guideline offered by Microsoft.
So basically all, follow it.
There are valid reasons to make a trivial property:
1) Reflection works differently on variables vs. properties, so if you rely on reflection, it's easier to use all properties.
2) You can't databind against a variable.
3) Changing a variable to a property is a breaking change.
4) a property can be easily bound to a control or other reflection-based controls that read all properties (rather than fields).
5) there may be actions that you want to perform in getters or setters (such as firing a NotifyPropertyChanged event).
Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif
krrishbiju-15589, if this helps please login to Mark As Answer. | Alert Moderator