为什么抽象类与接口比较。 [英] why abstract class is compare with interface.

查看:69
本文介绍了为什么抽象类与接口比较。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在c#中,抽象类应该与具体类进行比较?为什么大多数作者都在将抽象类与接口进行比较?

In c#, an abstract class is supposed to compare with concrete class? Why most of the authors are comparing abstract class with interface?

推荐答案

因为两者都只包含方法的签名,并且通常每个人都不知道何时使用抽象类和哪里使用interface。
Because both contains only signatures of methods and usually everyone doesn't know when to use abstract class and where to use interface.


如果您有一个概念,即抽象类只能与具体类进行比较,那么它是不正确的。在一篇体面的文章或书中,你会发现两者都有比较。主要是了解它存在的原因以及何时使用它。
If you have a notion that abstract class can only be compared to concrete class, then it is incorrect. In a decent article or book, you would find comparison to both. It is predominantly to understand why it exists and when to use it.


请参阅我对问题的评论以及我过去的答案。选择并非微不足道。我收集了所有过去答案的链接:

对界面的怀疑 [ ^ ]。



-SA
Please see my comment to the question and my past answers. The choice is not trivial. I've collected the links to all my past answers on one:
Doubts on Interfaces[^].

—SA


这篇关于为什么抽象类与接口比较。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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