The main difference is that if you need to add logic to your getter or setter, and other DLLs are already compiled against you, you can easily change
public string Name { get; set; }
in
public string Name { get{} set{} }
and it will not be a violation of changes to publish your new DLL and not recompile other DLLs.
If you changed
public string Name;
in
public string Name { get{} set{} }
then you will need to make sure that all the DLLs that use yours are recompiled as they change from accessing the field to accessing the property.
This is obviously a big problem when you send DLLs to other programmers (for example, an open source project or as a component provider) than if you just create an application for your own / employer
Rob Fonseca-Ensor
source share