Given that I have the following code:
interface IBase {
void DoStuff(double x, double y);
}
class Base : IBase {
public void DoStuff(double x, double y) { Console.WriteLine(x + y); }
}
Is it a good practice to override/hide the behavior of the base class without actually using the override
keyword? Are there any hidden pitfalls in the code below?
class Derived : Base {
public void DoStuff(double x, double y) { Console.WriteLine(x * y); }
}
Is it any better to use the new
keyword here? Like so:
class Derived : Base {
public new void DoStuff(double x, double y) { Console.WriteLine(x * y); }
}