1 Star 1 Fork 0

ClearStari99/C Sharp 教程

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
021 C Sharp 接口interface 接口继承.cs 916 Bytes
一键复制 编辑 原始数据 按行查看 历史
using System;
interface IParentInterface
{
void ParentInterfaceMethod();
}
interface IMyInterface : IParentInterface
{
void MethodToImplement();
}
// 以下实例 IMyInterface 继承了 IParentInterface 接口,因此接口实现类必须实现 MethodToImplement() 和 ParentInterfaceMethod() 方法
class InterfaceImplementer : IMyInterface // 如果一个接口继承其他接口,那么实现类或结构就需要实现所有接口的成员。
{
static void Main()
{
InterfaceImplementer iImp = new InterfaceImplementer();
iImp.MethodToImplement();
iImp.ParentInterfaceMethod();
Console.ReadKey();
}
public void MethodToImplement()
{
Console.WriteLine("MethodToImplement() called.");
}
public void ParentInterfaceMethod()
{
Console.WriteLine("ParentInterfaceMethod() called.");
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/ClearStari99/c-sharp-tutorial.git
git@gitee.com:ClearStari99/c-sharp-tutorial.git
ClearStari99
c-sharp-tutorial
C Sharp 教程
master

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385