PowerBuilder 11.5 includes support for functions that you call on .NET primitive and enumerated types. 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 means that you can 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()
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.
For a table of equivalencies between .NET and PowerScript primitive datatypes, see the chapter on “Referencing .NET Classes in PowerScript” in the Deploying Applications and Components to .NET book.
Function calls are also supported on .NET enumerated types that you import to a PowerBuilder .NET target. For example, suppose we 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
PowerBuilder 11.5 lets you use instance references to access static members of .NET classes. The following is an example of an instance reference you can use for a static member of the System.Web.HttpContext class:
string s
#if defined PBDOTNET then
//OLD WAY //s=System.Web.HttpContext.Current.ToString()
//NEW WAY
System.Web.HttpContext context context = create System.Web.HttpContext
s = context.Current.ToString() #end if