[go: up one dir, main page]

0% found this document useful (0 votes)
7 views3 pages

MultiLevel Inheritance

The document presents a C# code example demonstrating multi-level inheritance with three classes: Employee, Trainer, and TechnicalTrainer. The Employee class holds basic employee information, the Trainer class extends Employee to include training days, and the TechnicalTrainer class adds technology specialization. The MainClass creates an instance of TechnicalTrainer and displays its details.

Uploaded by

av859669
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

MultiLevel Inheritance

The document presents a C# code example demonstrating multi-level inheritance with three classes: Employee, Trainer, and TechnicalTrainer. The Employee class holds basic employee information, the Trainer class extends Employee to include training days, and the TechnicalTrainer class adds technology specialization. The MainClass creates an instance of TechnicalTrainer and displays its details.

Uploaded by

av859669
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Demo : Multi Level inheritance

using System;
class Employee
{
private int empId;
private string empName;

protected int EmpId


{
get { return empId; }
}

protected string EmpName


{
get { return empName; }
}

public Employee(int empId, string empName)


{
this.empId = empId;
this.empName = empName;
}
}

class Trainer : Employee


{
protected int trainingDays;
public Trainer(int empId, string empName, int trainingDays)
: base(empId, empName)
{
this.trainingDays = trainingDays;

}
}

class TechnicalTrainer : Trainer


{
private string technology;
public TechnicalTrainer(int empId, string empName, int trainingDays, string
technology) :
base(empId, empName, trainingDays)
{
this.technology = technology;
}
public void Display()
{
Console.WriteLine("EmpId={0}\nEmpName={1}\nTrainingDays={2}\
nTechnology={3}", EmpId, EmpName, trainingDays, technology);

}
}

class MainClass
{
static void Main(string[] args)
{
TechnicalTrainer obj = new TechnicalTrainer(100, "Nicholas", 100, ".Net");
obj.Display();
Console.Read();
}
}

Output:

You might also like