Murach's C# 2005
How to work with inheritance

This chapter shows you how inheritance is used throughout the .NET classes and how you can use inheritance in your own C# classes. When you're done, you'll know how to create base and subclasses, how polymorphism works, and how to use casting with inheritance. To make sure that you get all of that, this chapter presents a complete application that uses a Product base class, Book and Software subclasses, and a ProductList class that inherits the List<> class (one of the new typed collection classes available from .NET 2.0). Wow!

Chapter 14 How to work with inheritance
An introduction to inheritance 406
How inheritance works 406
How the .NET Framework uses inheritance 408
Methods inherited from the System.Object class 410
How to use inheritance in your applications 412
Basic skills for working with inheritance 414
How to create a base class 414
How to create a subclass 416
How polymorphism works 418
An inheritance version of the Product Maintenance application 420
The operation of the Product Maintenance application 420
The code for the Product, Book, and Software classes 422
The code for the ProductList class 426
The code for the Product Maintenance form 428
The code for the New Product form 430
Object types and casting 432
How to use the Type class to get information about an object's type 432
How to use casting with inheritance 434
How to work with abstract and sealed classes 436
How to work with abstract classes 436
How to work with sealed classes 438




Murach's C#

Learn more about this book

View the table of contents

Add this book to your cart



Our Ironclad Guarantee

First, try our books for 90 days. Then, if you aren't completely convinced that our books are the best ones you've ever used, you can return them for a full refund...no questions asked.