I've seen most people use member variables in a class like :
string _foo;
public string foo { get { return _foo; }; private set { _foo = value}; }
But what's the difference of that to this?
public string foo { get; private set; }
In simple cases like that its the same but in more complex cases where you fire events or something you need additional code in the get and set so you need the member ex:
private string _name;
public string Name
{
get{ return _name; }
set
{
SomeHandler("Name", value);
_name = value;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With