namespace ConsoleApplication7
{
interface Company
{
void onDuty();//接口的主题部分如果是方法则一定是公共抽象的,public abstract void onDuty();=void onDuty();
void offDuty();
}
class Employee : Company
{
public void onDuty()
{
Console.WriteLine("都在上班");
}
public void offDuty()
{
Console.WriteLine("都下班了");
}
}
class Program
{
static void Main(string[] args)
{
Employee employee=new Employee();
employee.onDuty();
employee.offDuty();
Console.Read();
}
}
}
//实现多个接口继承类
namespace ConsoleApplication9
{
abstract class Person
{
public void eat()
{
Console.WriteLine("person is eating!");
}
public abstract void breathe();
}
interface Company
{
void onDuty();
void offDuty();
}
class Employee : Person, Company
{
public void onDuty()
{
Console.WriteLine("is onduty!");
}
public void offDuty()
{
Console.WriteLine("is offduty!");
}
public override void breathe()
{
Console.WriteLine("is breathing!");
}
}
class Program
{
static void Main(string[] args)
{
Employee employee = new Employee();
employee.onDuty();
employee.offDuty();
employee.breathe();
Console.Read();
}
}
}