Chapter 12
Working with inheritance
After completing this chapter, you will be able to:
Understand what inheritance is and how it works.
Create a derived class that inherits features from a base class.
Control method hiding and overriding by using the
new
,virtual
, andoverride
keywords.Limit accessibility within an inheritance hierarchy by using the
protected
keyword.Define extension methods as an alternative mechanism to using inheritance.
Inheritance is a key concept in the world of object-oriented programming. You can use inheritance as a tool to avoid repetition when defining different classes that have some features in common and are quite clearly related to one another.
Suppose you’re writing an application to simulate a factory, ...
Get Microsoft Visual C# Step by Step, 10th Edition 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.