- C# 7 and .NET Core Cookbook
- Dirk Strauss
- 171字
- 2021-07-03 00:11:59
How it works...
So, you might be wondering what the difference between an abstract class and an interface is. It basically comes down to where you want your implementation. If you need to share functionality between derived classes, then an abstract class is the best fit for your needs. In other words, we had specific things that were common to all cats (lions, tigers, and cheetahs) such as hunting, eating, and sleeping. This is then best used within an abstract class.
If your implementation is specific to a class or several classes (but not all classes), then your best course of action would be to use an interface. In this case, the IPurrable interface can be applied to several classes (for example, cheetahs and domestic cats) but can't be applied to all cats (such as lions and tigers), because not all cats can purr.
Knowing this difference and where you need to place your implementation will aid you in deciding whether you need to use an abstract class or an interface.
- 多媒體CAI課件設計與制作導論(第二版)
- Implementing VMware Horizon 7(Second Edition)
- Java多線程編程實戰指南:設計模式篇(第2版)
- Python快樂編程:人工智能深度學習基礎
- 微信公眾平臺與小程序開發:從零搭建整套系統
- Objective-C應用開發全程實錄
- C#程序設計實訓指導書
- Visual C
- 快速念咒:MySQL入門指南與進階實戰
- Python時間序列預測
- Swift細致入門與最佳實踐
- SQL基礎教程(第2版)
- Getting Started with LLVM Core Libraries
- Lighttpd源碼分析
- Android移動開發案例教程:基于Android Studio開發環境