Virtual Methods and Properties
Learn to override methods and properties.
We'll cover the following...
Override methods
When we inherit a method from a base class, we might need to change its behavior in a child class. Consider the following example:
public class Animal
{
public void Voice()
{
// Method implementation
}
}
Let’s imagine that the Voice()
method produces the voice of an animal. For something as generic as the Animal
class, we could have a generic implementation of this method. But, for ...