-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinheritance.cs
50 lines (43 loc) · 1.2 KB
/
inheritance.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
namespace Inheritance
{
class Program
{
static void Main(string[] args)
{
//Inheritance allows for code re-use
//c# suuports single inheritence
//Multi level inheritance is allowed
//Parent class constructors are executed before
//child class constructors
FullTimeEmployee fte = new FullTimeEmployee();
fte.FirstName = "seefeesaw";
fte.LastName = "shongwe";
fte.YearlySalary = 5000000;
fte.PrintFullName();
PartTimeEmployee pte = new PartTimeEmployee();
pte.FirstName = "seefeesaw";
pte.LastName = "shongwe";
pte.HourlyRate = 1250;
pte.PrintFullName();
}
}
public class Employeee
{
public string FirstName;
public string LastName;
public string Email;
public void PrintFullName()
{
Console.WriteLine(FirstName + " " + LastName);
}
}
public class FullTimeEmployee : Employeee
{
public float YearlySalary;
}
public class PartTimeEmployee : Employeee
{
public float HourlyRate;
}
}