CHAPTER 18

image

Abstract

An abstract class provides a partial implementation that other classes can build on. When a class is declared as abstract it means that the class can contain incomplete members that must be implemented in derived classes, in addition to normal class members.

Abstract members

Any member that requires a body can be declared abstract – such as methods, properties and indexers. These members are then left unimplemented and only specify their signatures, while their bodies are replaced by semicolons.

abstract class Shape{   // Abstract method  public abstract int GetArea();    // Abstract property  public abstract int area { get; ...

Get C# Quick Syntax Reference 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.