Inheritance
Explore how inheritance works in C# by learning to create new classes from existing ones. Understand the roles of base and derived classes, how constructors operate, and how to use the base keyword to call parent constructors. This lesson prepares you to build specialized classes with shared characteristics.
We'll cover the following...
We'll cover the following...
What is Inheritance
-
Provides a way to create a new class from an existing class.
-
New class is a specialized version of the existing class.
-
Allows the new class to overload methods from the existing class.
Terminology
- Base Class(or Parent): inherited by child class.
- Derived Class(or child): inherits from base class.
Characteristics
A derived class has:
- All members defined in the derived class.
- All members declared in the base class.
A derived class can:
- Use all
publicmembers defined in the derived class. - Use all