在C#中需要的接口 [英] Need of interfaces in c#

查看:76
本文介绍了在C#中需要的接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是需要在c#接口?因为我们正在编写的接口抽象方法。而不是我们可以直接实现类的方法。

What is need of interfaces in c# ? as we are writing abstract method in interfaces. instead of that we can directly implement those methods in class.

推荐答案

接口不支持实现,所以你不能提供任何默认实现你可以与抽象类。此外,接口不局限于层次结构,所以它们比抽象类更灵活。

Interfaces don't support implementation, so you cannot supply any default implementations as you can with abstract classes. Additionally, interfaces are not restricted to hierarchies, so they are more flexible than abstract classes.

这篇关于在C#中需要的接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆