C#魔帅-lesson_04-接口

接口(Interface)

接口定义了所有类继承接口时应遵循的语法合同。
接口定义了语法合同 "是什么" 部分,派生类定义了语法合同 "怎么做" 部分。

定义接口

通常接口命令以 I 字母开头

interface IMyInterface
{
    void MethodToImplement();
}

接口继承

interface IParentInterface
{
    void ParentInterfaceMethod();
}

interface IMyInterface : IParentInterface
{
    void MethodToImplement();
}

class InterfaceImplementer : IMyInterface
{
  //实现
}

参考文档:http://www.runoob.com/csharp/csharp-interface.html

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。