I need a programming template, but I could not figure out what it would be. I'm not even sure if what I want is possible or not. Suppose I have a class Class Aand 10 inherited from A. I want the same method to Method Print()implement differently in each inherited class, but they all have to repeat the same method Class A.
Class A
{
public virtual void Print()
{
}
protected void StartingProcedure()
{
}
protected void EndingProcedure()
{
}
}
Class A_1 : A
{
public override void Print()
{
StartingProcedure();
EndingProcedure();
}
}
Class A_2 : A
{
public override void Print()
{
StartingProcedure();
EndingProcedure();
}
}
As you can see, I do not want to write StartingProcedure();for each overridden method Print. I want to automate this procedure when I inherit a new class from A. I don’t want to object to the Start and End procedures, I just want to write a print operation for a particular class. Is there any pattern that will provide me with this class behavior?
BTW I am working with C #