O'Reilly logo

Microsoft® Visual Basic® 2010 Developer’s Handbook by Klaus Löffelmann and Sarika Calla Purohit

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Constraints

Even though you can configure the DynamicList class to store values of any type, that flexibility might not always be desirable—especially when you are using generic types within a generic class, whose type you don’t yet know at design time.

Companion Content

Open the corresponding solution (.sln), which you can find in the \VB 2010 Developer Handbook\Chapter 17\Generics02 folder.

Constraining Generic Types to a Specific Base Class

Suppose that you have created an application that calculates, manages, and displays various kinds of 3D shapes (cubes, balls, pyramids, and so on). You want to create a generic class that saves the various shapes in a list like DynamicList, and calculates their total volume with a method that’s common to all ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required