Abstract Classes

Abstract classes and members are incomplete and must be implemented in a derived class.

  • They cannot be directly instantiated.
  • They cannot be static.
  • They may contain constructors.

Abstract, Concrete, Virtual, and Static Members

Abstract classes may contain abstract, concrete, virtual, and static members:

  • abstract members have no implementation.
    • They must be implemented in the derived class. Use the override keyword.
    • A field cannot be abstract.
    • They cannot be static.
  • Concrete members have an implementation. They are inherited in the derived class like normal.
    • They may be re-implemented in the derived class with the new keyword.
    • They may be static.
  • virtual members have an implementation. They are inherited in the derived class like normal.
    • They may be re-implemented in the derived class with the override keyword.
    • They cannot be static.
  • static members have an implementation.
    • They may be re-implemented in the derived class with the new keyword.
Member ModifierDefault ImplementationRe-implementKeywordStatic
abstractNoMustoverrideNo
virtualYesMayoverrideNo
(concrete)YesMaynewMay
staticYesMaynewYes

Sealed

The sealed keyword prevents inheritance of a class, or of class members that were previously marked virtual. Because a sealed class cannot be the base class of a derived class, it also cannot be abstract.