Object‐Oriented Programming with C#

Christian Nagel · 2018

This chapter covers how to create a hierarchy of classes and how polymorphism works with C#. It also describes all the C# keywords related to inheritance. The chapter reviews some object-oriented (OO) terms. It explores the different types of inheritance: single inheritance, multiple inheritance, multilevel inheritance and interface inheritance. C# allows both classes and methods to be declared as abstract. An abstract class cannot be instantiated, whereas an abstract method does not have an implementation and must be overridden in any nonabstract derived class. The constructors are always called in the order of the hierarchy. Modifiers can indicate the visibility of a method, such as public or private, or the nature of an item, such as whether a method is virtual or abstract. The chapter examines C#'s implementation of interfaces. It illustrates interfaces by presenting the complete definition of one of the interfaces that has been predefined by Microsoft: System.IDisposable.

Read the paper · More papers on PaperTik