using System;
public class Employee
{
public string FirstName;
public string LastName;
public string Email;
public void PrintFullName()
{
Console.WriteLine(FirstName + " " + LastName);
}
}
//C# doesn't provide multiful base classes
//public class FullTimeEmployee : Employee , A
//but multi level class is possible
public class FullTimeEmployee : Employee //Inheritance Syntax
{
public float YearlySalay;
}
public class PartTimeEmployee : Employee
{
public float HourlyRate;
}
//multiple level class
public class A: PartTimeEmployee
{
}
/*Pillars of Obejct Oriented Programming
* 1.Inheritance - allowed code reuse
* 2. Encapsulation
* 3. Abstraction
* 4. Polymorphism*/
public class Program
{
static void Main(string[] args)
{
//A a1 = new A();
//a1.FirstName = "test";
FullTimeEmployee FTE = new FullTimeEmployee();
FTE.FirstName = "Rody";
FTE.LastName = "Choi";
FTE.YearlySalay = 50000;
FTE.PrintFullName();
PartTimeEmployee PTE = new PartTimeEmployee();
PTE.FirstName = "Part";
PTE.LastName = "Time";
PTE.HourlyRate = 32;
PTE.PrintFullName();
}
}
===========================
using System;
public class ParentClass
{
public ParentClass()
{
Console.WriteLine("ParentClass Constuctor called");
}
public ParentClass(string Message)
{
Console.WriteLine(Message);
}
}
public class ChildClass : ParentClass
{
public ChildClass() : base("Derived class controlling Parent class") //making a default constructor
{
Console.WriteLine("ChildClass Constuctor called");
}
}
public class Program
{
static void Main(string[] args)
{
ChildClass cc = new ChildClass(); //called default constructor
}
}