Similarities between abstract classes and interfaces:
Abstract classes and interfaces both contain members that can be inherited by Derived classes. Both interfaces and abstract classes cannot be directly instantiated, but their variables can be declared. In this case, you can use polymorphism to specify the variables that inherit the two types of objects to them. Then use these variables to use these types of members, but cannot directly access other members of the derived object.
Differences between abstract classes and interfaces:
A derived class can only inherit one base class, that is, only one abstract class can be inherited directly (but multiple abstract classes can be contained in one inheritance chain ). On the contrary, classes can use any number of interfaces.
Abstract classes can have abstract members and non-Abstract members.
Abstract Member: it has no code body and must be executed in the derived class. Otherwise, the derived class itself must be abstract.
Non-Abstract members: They have code bodies or virtual ones, so that they can be rewritten in a derived class.
All interface members must be executed on the class using the interface-they have no code body.
Interface members are defined as public, abstract class members can also be private protected, internal, or protected internal members (the protected internal members can only be accessed in the application code or derived classes ). In addition, the interface cannot contain fields, constructors, destructor, static members, or constants.