25.7. Notes on Generics and Inheritance

Generics can be used with inheritance in several ways:

  • A generic class can be derived from a non-generic class. For example, class Object (which is not a generic class) is a direct or indirect base class of every generic class.

  • A generic class can be derived from another generic class. Recall that in Chapter 24, the non-generic Stack class (Fig. 24.13) inherits from the non-generic List class (Fig. 24.6). You could also create a generic Stack class by inheriting from a generic List class.

  • A non-generic class can be derived from a generic class with a specific type argument. Forexample, you can implement a non-generic AddressList class which inherits from a generic List class that stores Address objects.

Get Visual Basic 2005 for Programmers: Deitel Developer Series, Second 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.