I want to do something like this:
class Foo
{
bool Property
{
get;
set
{
notifySomethingOfTheChange();
// What should I put here to set the value?
}
}
}
Is there anything I can put there to set the value? Or will I have to explicitly define the get
and add another field to the class?
You either have a default property, with compiler-generated backing field and getter and/or setter body, or a custom property.
Once you define your own setter, there is no compiler-generated backing field. You have to make one yourself, and define the getter body also.
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