You can make function calls on .NET primitive and enumerated types from a PowerBuilder application. The function calls must be made inside a conditional compilation block for a .NET target.
To support function calls on .NET primitive types, the PowerBuilder .NET compiler (pb2cs) merges the functionality of these primitive types with the functionality of corresponding PowerBuilder primitive types. This allows you to use .NET primitive types and their corresponding PowerBuilder primitive types in a similar fashion. The following example makes the same ToString function call on both the .NET System.Int32 datatype and the PowerScript long datatype:
System.Int32 i1 long i2
i1.ToString() i2.ToString()
For a table of equivalencies between .NET and PowerScript primitive datatypes, see Table 14-3.
Exception for platform-specific primitive types The System.IntPtr and SystemUIntPtr primitive types do not have precise corresponding types in PowerBuilder—they are always treated as long datatypes. Calling functions or modifying properties on these .NET primitive types leads to a compilation error in PowerBuilder.
Function calls are also supported on .NET enumerated types that you import to a PowerBuilder .NET target. For example, suppose you define a .NET enumerated type in a .NET assembly as follows:
Public enum TimeOfDay { Morning = 0, AfterNoon, Evening }
PowerBuilder allows you to call the ToString method on the .NET TimeOfDay enumerated type after you import it to your target:
#if defined PBDOTNET then ns1.ns2.TimeOfDay daytime daytime = ns1.ns2.TimeOfDay.Morning! daytime.ToString() #end if