抽象类和接口在C# [英] Abstract classes and interfaces in C#

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

问题描述

可能显示的文件:结果
  接口VS基类结果
  接口或抽象类?

大家好,

我只是想着抽象类和接口,我知道他们在技术上是如何工作的,但我不明白真正使用抽象类和接口。
我的意思是,我们为什么要使用抽象类时,我们知道,我们不能创建它的对象,我们必须反正扩展这个类我们为什​​么不把在派生类中都使用它如此。

I am just thinking about the abstract classes and interfaces, I know how they work technically but i don't understand the real use of abstract classes and interfaces. I mean why should we use abstract classes when we know that we can't create it's object, we have to anyway extend this class to use it so why don't we put everything in the derived class.

同样是接口,我们必须实现的接口,所以我们为什么不把它们在类中,我们实现了接口的接口定义的所有方法。

Same is with interfaces, we have to implement the interface so why don't we put all the methods which are defined in the interface in the class in which we implement the interface.

可有人请清除我的疑虑一些例子?

Can someone please clear my doubts with some examples ?

推荐答案

在链接#1

其他

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

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