c# call child method from parent list -
i have following problem: have list of usercontrols wizard application , need call child method
list<usercontrol> steps = new list<usercontrol>(); steps.add(new step1()); steps.add(new step2()); steps.add(new step3()); steps.add(new step4());
all have stoptimeout() method. how can call: steps[0].stoptimeout();
?
thank you.
well, did it:
steps[0].stoptimeout();
just declare in base class of step classes stoptimeout
method protected
or public
example:
public step : usercontrol { .... public virtual void stoptimeout() { //base implementation } } public step1 : step { public override void stoptimeout() { //child implementation } } public step2 : step { public override void stoptimeout() { //child implementation } } ..
and in code:
list<step> steps = new list<step>(); steps.add(new step1()); steps.add(new step2()); ..
Comments
Post a Comment