From the course: Advanced C#: Object-Oriented Programming
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Inheritance - C# Tutorial
From the course: Advanced C#: Object-Oriented Programming
Inheritance
- [Instructor] One of the foundations of object-oriented programming is the concept of inheritance. And this is the process of defining classes that inherit their properties and methods from parent classes, so that you can reuse and customize the features and logic that they already have, without having to duplicate a whole lot of code. So here in chapter one, let's open up the inheritance folder. And we'll open up our program file and the shapes.cs file. So here in my example code, I have some classes that represent two dimensional shapes. So at the top I've got Shape2D, which serves as the base class for the other shapes. And there are two classes that derive from Shape2D, and they are circle and rectangle. The definition for each of these indicates Shape2D as the super class from which they derive. The circle has a radius value. And the rectangle, if we scroll down, has a width and a height. And I have some code…