Automatic Properties in C# 3.0
April 2, 2009
We just upgraded our servers to support .Net 3.x, so at last I'm able to start migrating some of my code. I haven't taken a close look at all the features available yet, but one that caught my eye and initially excited me is automatic properties. However, I had two conflicting reactions:
- This is great, I don’t have to create a private field and write getter/setter in a public Property anymore.
- But then what’s the point of not just creating a public field and using it directly?
Well, this article addresses a primary benefit: this facilitates refactoring. If, for instance, we find later on that we need something more advanced than a simple get or set statement, then we can add it without breaking the interface. I'm sold.
TrackBack URL: http://www.safnet.com/fcgi-bin/mt/mt-tb.cgi/37