Public Class FooBar
{
private int _foo;
public int Foo {
get { return _foo; }
set { _foo = value; }
}
public void DoStuff()
{
_foo++; // Do this?
Foo++; // Or this?
}
}
Is there a more accepted practice to either access fields or properties (if one exists) in a class? I've always been in the habit of accessing the field, but since I've been doing WPF which has a lot of INotifyPropertyChanged, I've found myself needing to access the Property to get the notification changed. So now I have a mix of both field and property accesses throughout my classes and while from a compiler point-of-view it doesn't matter, stylistically and readability, it feels...awkward.