xxxxxxxxxx
- Method overriding means changing the implementation of an inherited method.
- If a declare a method as virtual in the base class, we can override it in
derived class.
- This technique allows us to achieve polymorphism. Polymorphism is a great
object oriented technique that allows use get rid of long procedural switch
statements (or conditionals).
// Code Example:
public class Shape
{
public virtual Draw()
{
// Default implementation for all derived classes
}
}
public class Circle : Shape
{
public override Draw()
{
// Changed implementation
}
}