csharp-in-style
csharp-in-style copied to clipboard
Properties with backing members
i think that this:
public string Name {
get { return name; }
set { name = value; }
} protected string name;
is better than this:
string name;
public string Name {
get { return name; }
set { name = value; }
}
Yes, I see the merit to this but it's also a bit baroque. If the backing field came after the property, I would definitely not put it on the same line as the closing brace of the property.
public string Name {
get { return name; }
set { name = value; }
}
string name;
This is especially advantageous when the property has lots of attributes...
@bryancostanich next time please format your code snippets correctly–see how I added the fenced code blocks.
that's fine, as long as it comes after, as it's easier to parse. i don't know if it's baroque though, i actually like it because it hides the backing field, visually. :)