Saturday, June 29, 2013

C# 2.0 property or the underlying field for assignment?

Always use the properties. Especially in class code! In fact you should ignore the existence of the Private Varriable behind the property totally. You never know when something get's added to the Properties setter code (like change Notification) and at such a point not using the Property anywhere could be a gamebreaker.


Also as a sort of convention the private backing varriables should start with an underscore (private string _ParamName). That way you can prevent misunderstandings. More then one person ran into serious problems later on because he accidently accessed the backing varriable isntead of the property.




Let's talk about MVVM: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/b1a8bf14-4acd-4d77-9df8-bdb95b02dbe2


No comments:

Post a Comment