virtual methods, in base class, have very basic implementation. Even if we
override the definition of
virtual method in child class, we can still call the
virtual method (with basic implementation) while it makes sense and does not affect the intended behavior of the
overridden method in the child class.
BaseCalculator does the real work. Calculator is decorating the BaseCalculator library by extending it.
public class BaseCalculator
public virtual T Add<T>(T number01, T number02)
return number01 + number02;
public class Calculator: BaseCalculator
public override T Add<T>(T number01, T number02)
Console.WriteLine(number01 + " | " + number02);
var result = base.Add<int>(1, 3);
Console.WriteLine("Result: "+ result);
Q: What if an overridden method only calls the base class?
A: In your case, having base class method as
virtual, we need not to
override it until we want to change its behavior.
Q: Is this bad/good deign?
A: Yes, it could bad design as it may clutter the source code file while we add unnecessary overrides.
Q: It just seems odd, why override a method just to call the base anyway?
A: BaseCalculator does the real work. Calculator is decorating the BaseCalculator library by extending it.
Hope, it helps!