Inheritance
Letting a class reuse and extend the data and methods of another class.
What is Inheritance?
Inheritance lets one class build on another. The new class gets all the data and methods of the existing class and can add or change some. A Cat class can inherit from Animal and add a Purr method.
public class Animal
{
public string Name { get; set; }
public void Eat() => Console.WriteLine( quot;{Name} is eating");
}
public class Cat : Animal
{
public void Purr() => Console.WriteLine("Purrr");
}
Level: Apprentice · More OOP terms at this level
Updated