Appendix B. Solutions

Introducing Interfaces

Solution 2.1

from page 10

An abstract class with no non-abstract methods is similar to an interface in terms of its utility. However, note the following:

  • A class can implement any number of interfaces, but can subclass at most one abstract class.

  • An abstract class can have non-abstract methods; all the methods of an interface are effectively abstract.

  • An abstract class can declare and use variables; an interface cannot.

  • An abstract class can have methods whose access is public, internal, protected, protected internal, or private. Interface members implicitly have public access, and no access modifiers (including public) are allowed on interface member declarations.

  • An abstract class can define constructors; ...

Get Design Patterns in C# now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.