Visual RPG 8.2 and above support the consumption of generic types and generic methods, which opens the door to using all generic collection classes in the Systems.Collections.Generic namespace. Generics are a feature of the .NET framework, and defer the data type until they are used. They allow the code to remain the same; however the data tpe of the parameters can change with each use.
The advantages of using generics is that they enforce type consistency at compile time; not at run-time; and eliminate the need for casting at runtime, making programming errors easier to catch. They also make it clear what type of object a generic type can handle.
The syntax for using generic types is:
<type name > ( *Of<list of types> )
e.g. List(*Of Customer)
A generic type can be used in the following:
1. In any place a type is used in AVR; e.g. as a parent class:
BegClass MyClass Extends( Dictionary( *Of
*integer4, *string))
2. As a field type, such as:
DclFld MyFld type( List(*Of PurchaseOrder))
- or- as the type of a BegFunc, DclSrParm, DclArray, etc
The syntax for calling generic methods is:
<method name>( *Of<list of types>) (<method parms>)
e.g. CreateList( *Of *integer4)( 1i, 2i, 3i, 4i)
Setting Project Designer Properties