using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication11
{
class Program
{
static void Main(string[] args)
{
worker worker1 = new worker();
worker1.Name = "張三";
worker1.ID = "12345";
worker1.Work();
wage wage2 = new wage();
wage2.Wage();
Console.ReadLine();
}
}
public interface myInterface //新建一個接口類,默認修飾符是pulic。
{
//設置Name和Id屬性
string Name //接口可以包含方法,屬性,事件,索引器,但是不包含字段。
{
get;
set;
}
string ID
{
get;
set;
}
//設置一個work方法
string Work();//接口類不包含方法的實現
}
public class worker : myInterface //新建一個工作類繼承myInterface
{
string id = "";
string name="";
public string Name
{
get
{
return name;
}
set
{
name = value;
}
}
public string ID
{
get
{
return id;
}
set
{
id = value;
}
}
public string Work()
{
Console.WriteLine(name);
Console.WriteLine(id);
return name;
}
}
public class wage:worker,myInterface //新建一個工資類,繼承工作類,和接口類。接口可以多重繼承。使用多重接口時,要繼承的接口之間用,分隔
{
public void Wage()
{
Console.Write("5000K");
}
}
}