I have a property that is currently automatic.
public string MyProperty { get; set; }
However, now I need it to perform some action every time it changes, so I want to add logic to the setter. So I want to do something like:
public string MyProperty { get; set { PerformSomeAction(); } }
However, this does not create ... MyProperty.get' must declare a body because it is not marked abstract, extern, or partial
I cannot just return the getter MyProperty , as this will cause an infinite loop.
Is there a way to do this, or do I need to declare a private variable to be referenced? I would prefer not to use MyProperty through the code both in this class and outside it
c #
colmde
source share