Syntax for Consuming Generic Classes

Generics are classes, structures, interfaces, and methods with placeholders for the datatypes that they store or use.

A generic collection class can use a datatype parameter as a placeholder for the types of objects that it stores or returns. A generic method can also use its datatype parameter as a type for any of its formal parameters (arguments).

In PowerBuilder .NET, you can consume .NET generic classes and methods that conform to CLS generic rules. However, you cannot define a generic type or override generic methods.

This example calls the generic SortedList method:
System.Collections.Generic.SortedList<string, integer> teams
teams = create System.Collections.Generic.SortedList<string, &
   +integer>
teams["DEV"] = 30
teams["QA"] = 25
The generic parameter type can be any type, including a primitive type, .NET class type, PowerBuilder user-defined type, or a nested generic type. Inner generic types are also supported. For example:
MyDll.GenericClass2<MyDll.Class1>.GenericClass2_1<System.String> o1
o1 = CREATE MyDll.GenericClass2<MyDll.Class1>.GenericClass2_1 &
   +<System.String>
 
The syntax for calling functions of .NET classes is also available for the .NET generic type. For example:
       string p1 = "p1", p2 = "p2"
       MyDll.GenericClass1<MyDll.Class1> o2
       o2 = CREATE MyDll.GenericClass1<MyDll.Class1>
       
       //Calling a normal function of the .NET generic type 
       //with the Dynamic keyword 
       o2.Dynamic GenericTest11(p1, p2)  

       //Calling a generic function of the .NET generic type 
       //with the Dynamic keyword   
       o2.Dynamic GenericTest12<MyDll.MyClass2>(p1, p2) 

       //Calling a generic function of the .NET generic type 
       //with Dynamic and Post keywords 
       o2.Dynamic POST GenericTest11<MyDll.MyClass2>(p1, p2)

       //Calling a generic function of the .NET generic type   
       //with Post and Dynamic keywords 
       o2.POST Dynamic GenericTest12<MyDll.MyClass2>(p1, p2)