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

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -