【转载】#446

An abstract class is a base class that may have some members not implemented in the base class, but only in the derived classes. An interface is just a contract that a class can choose to fulfill - a list fo member that it must implement if it implements the interface.

You'll often use an abstract class when you use nouns to describe the is-a relationship between a base class and derived classes. E.g. Person as an abstract class and Man and Woman as derived classes.

By contrast, you'll often use interfaces when you think about verbs that describe things that instances of a class can do. E.g. IRun interface containing Run method, implemented by Man and Woman, but also Horse classes.

1 public abstract class Person
2 // ...
3 
4 public class Man: Person, IOperateTools, IDriveTractor
5 // ...
6 
7 public class Woman: Person, IAskForDirections, ICollaborate
8 // ...

原文地址:#446 - Deciding Between an Abstract Class and an Interface

原文地址:https://www.cnblogs.com/yuthreestone/p/3596789.html