Inheritance for Classes

The first thing we want to look at is how to derive a class from another one. C# uses a single syntax for inheritance both from a class or a set of interfaces, which is different from languages like Java, in which two keywords, extends and implements, are used. In the following example, we explicitly derive a class from System.Object:

image

The preceding code is no different from omitting the colon and base type altogether because Object is the default base type if left unspecified:

image

Where things get more interesting is when ...

Get C# 4.0 Unleashed 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.