Home > Net >  How to limit the superclass constructor call time?
How to limit the superclass constructor call time?

Time:02-23

Have an egg pain,
 public class Parent 
{
Public Parent ()
{
The Init ();
}

Protected virtual void Init ()
{
}
}

Child: public class Parent
{
Private int someproperty=1;
Public Child (int I) : the base ()
{
Enclosing someproperty=I;
}

Protected override void Init ()
{
//this time I will always be the initial value 1
If (I==0)
Dosomething
}
}


The parent is a library class, the init method is used in the interface drawing, I want to use an attribute to control the effect of the interface drawing, but the execution order is:
The Child (int I) - & gt; The base () - & gt; The init () - & gt; Enclosing someproperty=I;

So I want to don't reach the effect of
  •  Tags:  
  • C#
  • Related