接口与实现
接口 实现
2023-09-27 14:24:30 时间
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Demo
{
public interface IMyInterface
{
void DoSomething();
void DoSomethingElse();
}
public class MyClass : IMyInterface
{
public void DoSomething()
{
Console.WriteLine("DoSomething");
}
public void DoSomethingElse()
{
Console.WriteLine("DoSomethingElse");
}
}
class Program
{
static void Main(string[] args)
{
MyClass myObject = new MyClass();
myObject.DoSomething();
myObject.DoSomethingElse();
Console.ReadKey();
}
}
}
一个类,如果继承了某个接口。那么它必须把接口的方法都实现了,哪怕是一个空的。
相关文章
- 使用GraphQL开发房源接口 、实现房源列表查询的接口、 搭建前台系统 实现首页轮播广告功能、 改造轮播广告接口方式为GraphQL
- 【Python开发】C和Python之间的接口实现
- 【Python开发】C和Python之间的接口实现
- 【神经网络与深度学习】【Matlab开发】caffe-windows使能Matlab2015b接口
- 【基于ChatGPT+SpringBoot】打造智能聊天AI机器人接口并上线至服务器
- Effective Java 第三版——64. 通过对象的接口引用对象
- Effective Java 第三版——14.考虑实现Comparable接口
- 一文3000字从0到1实现基于requests框架接口自动化测试项目实战(建议收藏)
- 接口测试很难?3分钟带你入门接口自动化测试...
- 94.(后端)分类参数ID获取接口实现——restful发送请求查询数据
- ImportBeanDefinitionRegistrar接口实现bean动态注入
- 这个匿名对象没有实现IComparable接口
- 还需要编写DAO代码吗?SQL+接口就足够了!
- python+requests实现接口测试 - get与post请求使用(转载)
- openTCS Http接口创建运输订单
- 【Springboot之切面编程】注解实现接口防刷
- Java对象为啥要实现Serializable接口?
- Java序列化为什么必须实现 Serializable 接口???
- Mybatis系列第5篇:Mapper接口多种方式传参详解、原理、源码解析
- WebRTC系列---iOS平台接口介绍及demo示例(2)
- FastAPI 学习之路(四十八)WebSockets(四)接口测试
- Python 接口测试(三)