Understanding Generics and Nullable Data Types
Generics can arguably be viewed as the major enhancement provided by VB 2005. As you have seen, a generic item allows you to specify “placeholders” (i.e., type parameters) that are specified at the time of creation (or invocation, in the case of generic methods). Essentially, generics provide a solution to the boxing and type-safety issues that plagued .NET 1.1 development.
While you will most often simply make use of the generic types provided in the .NET base class libraries, you are also able to create your own generic types. When you do so, you have the option of specifying any number of constraints to increase the level of type safety and ensure that you are performing operations on types of a “known quantity.”
KeywordsType Parameter Module Program Public Function Type Safety Public Class
Unable to display preview. Download preview PDF.