Skip to main content

Multi-level Inheritance

Multi-level Inheritance in C#
When one class acquires another class which is additionally acquired by another class, in this case, we will call it Multi-level Inheritance. Inheritance is transitive so the last decided class secures all of the information from all its base classes.so let's clear out through the program and simply copy the yellow highlighted code as follows.

Program

using System;
namespace program
{
    public class Car      /*Base class */
    {
        public void BMW()
        {
            Console.WriteLine("Manufracturer- BMW_Ltd_Corporation");
            Console.WriteLine("Car_Brand - BMW");
        }
    }
    public class BMW_Feature : Car
    {
        public void feature()
        {
            Console.WriteLine("Avalble_Color- Black,Blue,Red,White ");
            Console.WriteLine("Max_Speed - 200 MPH ");
            Console.WriteLine("Price=23,00000");
        }
    }
    public class Detail: BMW_Feature /*Derived class */
    {
        public void Bmw_Detail()
        {
            BMW();
            feature();
        }
    }
   
    class Inheritance
    {
        class Program
        {
            static void Main(string[] args)
            {
    /*Calling all the base classes members using drived class*/
             Detail Car = new Detail();
             Car.Bmw_Detail();
             Console.ReadKey();
            }

        }
    }
}

Now you can see in the above program last Derived class is Detail which acquires all the members of all its base classes.

Output
Manufacturer- BMW_Ltd_Corpration
Car_Brand -BMW
Available_Color-Black, Blue, Red, White
Max_Speed-200 MPH
Price-23,00000

Popular posts from this blog

Media Player in C# Visual Studio By Rohit Programming Zone

Media Player  in C# Visual Studio   Source Code ----------------------------------------------------------------------------------------------------------------------------- using System; using System.Windows.Forms;   namespace Media_Player_in_C_Sharp_By_Rohit_Programming_Zone {     public partial class Form1 : Form     {         public Form1()         {             InitializeComponent();         }         string [] paths, files;           private void btn_open_Click( object sender, EventArgs e)         {             OpenFileDialog ofd = new OpenFileDialog ();   ...

ImageEditor in C# Visual Studio 2017

ImageEditor in C # Start a new project in Visual Studio > choose Visual C# then click on Windows Desktop then select WindowsForm App(.Net Framework)  and name it as ImageEditor then press ok. First, go to the Form1 properties  S ection and set the Size as following. Form1-size=952, 607 Now Add 3 panels from the toolbox and set the properties as follows. After setting the properties it will look as follows. Now Add 2-picture box from the toolbox and go to the properties and set the properties as follows. Now add 15-Button from the toolbox. Now add 3-textbox from the toolbox. Now add 3-trackbar and 5-label from the toolbox. Now go to the properties section and check all the Components are named correctly or not. Once  all the Components are named correctly then  move to the coding part. (Now the Coding Part) Now go to the Form1 code view and  ...

Microsoft tools Download

1-Visual Studio Code Visual Studio Code is a  fast and free  source code lite editor that can be used with the various programming languages. Download 2-Visual Studio 2019 Community Download 3-Microsoft Visual Studio 2010 Microsoft Visual Studio 2010 Development environment specialized in Windows systems. Download 4-VISUAL STUDIO 2013 EXPRESS FOR WEB Visual Studio Express 2013 for Web provides the core tools for creating compelling, innovative web applications and services. This includes the ASP.NET editors for HTML5, CSS3, JavaScript, etc. Download 5-Piskel Download 6-Pichon Download 7-Microsoft XNA Framework Redistributable 4.0 Description The XNA Framework has all the necessary runtime components to execute a game, which was developed using Microsoft XNA Game Studio 4.0. Version 4.0 of the framework contains improved functionality and new features.