namespace InterfaceTpye2
{
interface IPeople
{
string Name //姓名
{
get;
set;
}
string Sex;//性别
{
get;
set;
}
}
interface ITeacher:IPeople
{
void teach();
}
interface IStudent:IPeople
{
void study();
}
class Program:IPeople,ITeacher,IStudent
{
string name;
string sex;
public string Name
{
get
{
return name;
}
set
{
name = value;
}
}
public string Sex
{
get
{
return sex;
}
set
{
sex = value;
}
}
public void teach()
{
Console.WriteLine(Name + " " + Sex + "教师");
}
public void study()
{
Console.WriteLine(Name + " " + Sex + "学生");
}
static void Main(string[] args)
{
Program program=new Program();
ITeacher iteacher = program;
iteacher.Name = "陈老师";
iteacher.Sex = "男";
iteacher.teach();
IStudent istudent = program;
istudent.Name = "小郑";
istudent.Sex = "男";
istudent.study();
}
}
}