Whats the difference now between doing this:
public string Title { get; set; }
and this:
public string Title;
Back in the day people always said use accessor methods with private variables called by the public accessor, now that .net has made get; set; statements so simplified that they look almost the same without the private variable as just using a public only variable, so whats the point and difference?
I have an article on this: Why properties matter.
In short: properties are part of an API. Fields are part of an implementation. Don't expose your implementation to the world. You can change an automatically implemented property to have more behaviour (maybe logging, for example) in a source and binary compatible way. You can't do that with a field.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With