2
using System;
namespace inheritance1
{
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 YearlySalary;
}
public class PartTimeEmployee : Employee
{
public float HourlyRate;
}
public class Program
{
public static void main(String[] args)
{
FullTimeEmployee FTE = new FullTimeEmployee();
FTE.FirstName = "Max";
FTE.LastName = "Striker";
FTE.YearlySalary = 500000;
FTE.PrintFullName();
PartTimeEmployee PTE = new PartTimeEmployee();
PTE.FirstName = "king";
PTE.LastName = "Maker";
PTE.HourlyRate = 500;
PTE.PrintFullName();
}
}
}
Habib的回答就是這樣。有趣的是,項目模板應該已經正確地爲你設置了一切......你在使用VS嗎? –
@ rory.ap我懷疑這是來自模板! – DavidG
它看起來不像他實際上使用任何模板。編輯:@DavidG忍者哈哈 –