抽象类和接口在C# [英] Abstract classes and interfaces in C#
问题描述
大家好,
我只是想着抽象类和接口,我知道他们在技术上是如何工作的,但我不明白真正使用抽象类和接口。
我的意思是,我们为什么要使用抽象类时,我们知道,我们不能创建它的对象,我们必须反正扩展这个类我们为什么不把在派生类中都使用它如此。
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
- 的确切使用抽象类
- 接口或抽象类?
- 抽象类VS接口
- Why做到既抽象类和
接口在.net中存在? - differences一个抽象类之间
而在C# 接口 - What’s一个之间的差
接口和抽象类? - When使用一个接口代替
一个抽象类,反之亦然? - Help我明白在实际
例如使用抽象类VS
接口?
- Exact use of Abstract class
- Interface or abstract class?
- Abstract classes vs Interfaces
- Why do both the abstract class and interface exist in .Net?
- differences between an abstract class and an interface in C#
- What’s the difference between an interface and an abstract class?
- When to use an interface instead of an abstract class and vice versa?
- Help me understand in a practical example the usage abstract classes vs interfaces?
其他
- 抽象类与接口
- 的我应该用一个抽象类或
接口? - 抽象基类在接口
- 了解:当使用一个抽象
类和接口 - 作为抽象类的建议
与接口 - MSDN - 与抽象类的工作,密封
类和接口在C# - abstract class和区别
接口在C#(.NET)
- Abstract Class versus Interface
- Should I use an abstract class or an interface?
- Abstract base class over interface
- Learn This: When to use an Abstract Class and an Interface
- Recommendations for Abstract Classes vs. Interfaces - MSDN
- Working with Abstract classes, Sealed Classes, and Interfaces in C#
- Difference between Abstract class and Interface in C# (.Net)
这篇关于抽象类和接口在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!