3 ms·
For c# just: public int Age{get;set;} no need to declare private variable, get or set methods.
by hugozap 12y ago
For c# just:
public int Age{get;set;}
no need to declare private variable, get or set methods.
- Tloewald 12y agoAnd you can replace it with a virtual property in the future (changing the underlying implementation) without breaking anything. And user code ends up simpler and more readable too: foo.baz += foo.bar; vs. foo.setBaz( foo.getBaz() + foo.getBar() );
- HanyouHottie 12y agoThat example reminds me of this recent post on The Old New Thing: http://blogs.msdn.com/b/oldnewthing/archive/2014/08/14/10549885.aspx http://blogs.msdn.com/b/oldnewthing/archive/2014/08/14/10549... Interesting behavior.
- Tloewald 12y agoOf course, setters don't protect you from this either.