inheritance - C# calling parent property while the child property is being called -


i wanna see if there anyway when child property method being called, call parent property well. note child generated code generator edmx. can't change except adding partial class child class. (it might trouble change generator.)

the situation having : have class "myclass" automatically generated database. can't change on except adding partial class or change code generator.

now, need "do something" whenever property name being called. thinking if can put parent there , make call parent "something" when child property "name" being called.

what want :

public class classbase {     public string name      {                   {              callmethod();             return name;         }     } }  public class myclass : classbase  {     public string name { get; set; } }   myclass myclass = new myclass(); myclass.name; < -- call parent well. 

is there anyway it?

thanks in advance

not related since you're not strictly using automatic properties in classbase, should create private string variable name. _name or whatever internal coding standards dictate.

public class classbase {   private string _name;   public virtual string name    {           {        callmethod();       return _name;     }     set     {       _name = value;     }   } }   public class myclass : classbase  {   //pretty pointless since you're not doing myclass.name.   public new string name   {         {       return base.name;     }     set     {       base.name = value;     } }   myclass myclass = new myclass(); myclass.name; <-- call parent well. 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -