c# - Call method/execute piece of code using Property attribute -


just wondering if it's possible call method using property attribute. basically, want set state of entity when of public property changes.

like have following code

public class contact : entitybase {     [notifychange]     public string firstname { get; set; }      private void changestate()     {        entitystate = entitystate.modified;     } } 

and when call

var c = new contact(); c.firstname = "john"; 

before (or after) setting value of firstname, call entitystate() function.

any idea?

it simpler if property rewritten as:

public class contact : entitybase {      private string _firstname;      [notifychange]     public string firstname     {                 {             return _firstname;         }         set         {             changestate();             _firstname = value;         }     }      private void changestate()     {        entitystate = entitystate.modified;     } } 

Comments

Popular posts from this blog

hibernate - How to load global settings frequently used in application in Java -

objective c - Ownership modifiers with manual reference counting -

python 3.x - Mapping specific letters onto a list of words -