RAD Studio (Common)
ContentsIndex
PreviousUpNext
Generics (Parameterized Types)

Presents an overview of generics, a terminology list, a summary of grammar changes for generics, and details about declaring and using parameterized types, specifying constraints on generics, and using overloads.

Name 
Description 
Delphi for .NET supports the use of generics, also known as parameterized types. 
 
The declaration of a generic is similar to the declaration of a regular class, record, or interface type. The difference is that a list of one or more type parameters placed between angle brackets (< and >) follows the type identifier in the declaration of a generic.
Type parameters can be used as a typical type identifier inside the container type declaration and method body.
For example:  
 
Constraints can be associated with a type parameter of a generic. Constraints declare items that must be supported by any concrete type passed to that parameter in a construction of the generic type. 
The class variable defined in a generic type is instantiated in each instantiated type identified by the type parameters.
The following code shows that TFoo<Integer>.FCount and TFoo<String>.FCount are instantiated only once, and these are two different variables.  
Here is a list of standard function changes to support parameterized types. Example forms:  
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!