I like to organize simple properties like this:
private int foo;
public int Foo
{
get { return foo; }
set
{
// validate value
foo = value;
}
}
I've been playing around with StyleCop, and it yells at me for placing fields after constructors. Is this style generally accepted, as long as the field is never referenced outside of the property? Note: I realize that there is personal preference involved, but I am wondering if there is a general consensus regarding this issue.