C# OOP/

Inheritance

Inheritance is one of the fundamental concepts of Object-Oriented Programming (OOP) and is supported in C#. Inheritance allows a class to inherit properties and behaviors from a parent class. The child class is referred to as the derived class, while the parent class is referred to as the base class.

Defining a Derived Class

A derived class is defined using the class keyword followed by the derived class name and a colon : followed by the base class name.

Here is an example of a derived class in C#:

In this example, the SportsCar class inherits from the Car class and adds a new property HasTurbo and a new method EngageTurbo.

}

ZetBit

Subscribe to ZetBits Newsletter