Yes, this feature should’ve introduced ages ago
This post covers a pre-release C# 6.0 feature. It’s possible that the final implementation may differ from what’s described here.
I’ve lost track of the number of times I’ve needed to pass along the name of something be it a property, method, or type. Historically we’ve relied on hard-coded strings to convey this information but as we’re all too well aware, relying on strings in such a manner is just asking for future problems. For a prime example, we need look no further than our old friend INotifyPropertyChanged.
Consider the following Circle class which typifies the basic INotifyPropertyChanged implementation pattern:
Although this class is pretty boilerplate, it highlights the problem well. First, we’ve violated the DRY principle by encoding a member name in a string. Next, we’ve introduced fragility by relying on the string always reflecting the property name exactly; should the property name ever change we need to…
View original post 492 more words