在项目中我们将在哪里使用接口和抽象类? [英] Where we will use Interfaces and abstract classes in project?

查看:82
本文介绍了在项目中我们将在哪里使用接口和抽象类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小疑问.我们将在项目中使用确切的接口和抽象类.


有人可以澄清一下吗....

I have a small doubt. where we will use exactly interfaces and abstract classes in project.


Can any one clarify me...please.

推荐答案

希望这会有所帮助

抽象类与接口 [
Hope this helps

Abstract Class versus Interface[^]


您做了什么研究?

接口是合同,它不包含任何代码.抽象类可以具有代码.在.NET中,您不能从多个类派生,但是可以实现多个接口.

抽象类与接口 [
And what research have you done?

An interface is a contract, it contains no code. An Abstract class can have code. In .NET you can''t derive from multiple classes however you can implement multiple interfaces.

Abstract Class versus Interface[^]


我已经回答了类似的问题.除了其他答案外,请参见有关如何决定使用接口还是抽象类的讨论:
I already answered similar question. In addition to other Answers, please see the discussion on how to decide on use of interfaces vs. abstract classes: How to decide to choose Abstract class or an Interface[^].

Also, one fundamental difference is that interfaces allows for multiple inheritance, in contrast to classes (abstract or not). This is called week form of multiple inheritance and has serious design implications.

—SA


这篇关于在项目中我们将在哪里使用接口和抽象类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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