|
Post by Admin on Jun 6, 2014 21:31:36 GMT -5
1. using System;
public class Employee
{
public string FirstName;
public string LastName;
public string Email;
public void PrintFullName()
{
Console.WriteLine(FirstName + " " + LastName);
}
}
public class FullTimeEmployee : Employee
{
public float YearySalary;
}
public class PartTimeEmployee : Employee
{
public float HourlySalary;
}
public class Program
{
public static void Main()
{
FullTimeEmployee FTE = new FullTimeEmployee();
FTE.FirstName = "Hieu";
FTE.LastName = "Luong";
FTE.YearySalary = 50000;
FTE.PrintFullName();
PartTimeEmployee PTE = new PartTimeEmployee();
PTE.FirstName = "Bin";
PTE.LastName = "Joe";
PTE.PrintFullName();
}
}
2. using System;
public class ParentClass
{
public ParentClass()
{
Console.WriteLine("ParentClass Constructor called");
}
public ParentClass(string Message)
{
Console.WriteLine(Message);
}
}
public class ChildClass : ParentClass
{
public ChildClass() : base("Derive class controlling Parent class")
{
Console.WriteLine("ChildClass Constructor called");
}
}
public class Program
{
public static void Main()
{
ChildClass CC = new ChildClass();
}
}
|
|