接口只声明、无实现、不能实例化;
接口可包含方法、属性、事件、索引器, 但无字段;
接口成员都是隐式的 public, 不要使用访问修饰符;
类、结构和接口都可以继承多个接口;
继承接口的类必须实现接口成员, 除非是抽象类;
类实现的接口成员须是公共的、非静态的
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//入户门式列
interface MyInterface
{
int Sqr(int x);
}
class MyClass:MyInterface
{
public int Sqr(int x)
{
return x * x;
}
}
interface ImyInterface
{
int Method(int x, int y);
}
class MyClass1:ImyInterface
{
public int Method(int x,int y)
{
return x + y;
}
}
class MyClass2:ImyInterface
{
public int Method(int x,int y)
{
return x - y;
}
}
interface