Public Fields versus Automatic Properties

In a related question I had some time ago, there was a link to a posting on Jeff’s blog, explaining some differences.

Properties vs. Public Variables

  • Reflection works differently on variables vs. properties, so if you rely on reflection, it’s easier to use all properties.
  • You can’t databind against a variable.
  • Changing a variable to a property is a breaking change. For example:

    TryGetTitle(out book.Title); // requires a variable
    

Leave a Comment