When you use conditional blocks of code for the .NET environment, you can take advantage of the following features that are not available in the standard PowerBuilder application environment:
Support for sbyte and ulonglong Sbyte is the signed format of the byte datatype and ulonglong is the unsigned format of the longlong datatype.
Bitwise operators See “Bitwise operator support”.
Parameterized constructors Arguments are not permitted in constructors for standard PowerBuilder applications, but they are supported in conditional code blocks for the .NET environment.
Static fields and methods Static fields and methods are not permitted in standard PowerBuilder applications, but they are supported in conditional code blocks for the .NET environment. You can use instance references to access static members of .NET classes, as in the following example for the static property “Now” of the System.DateTime class:
#if defined PBDOTNET then
System.DateTime dt_instance
System.DateTime current_datetime
dt_instance = create System.DateTime
current_datetime = dt_instance.Now
#end if
Alternatively, you can access static .NET properties without using instance references, as the following code illustrates:
#if defined PBDOTNET then
System.DateTime current_datetime
current_datetime = System.DateTime.Now
#end if
Namespaces, interfaces, and user-defined enumerations You can reference namespaces and .NET interfaces and enumerations in conditional code blocks for the .NET environment. In standard PowerScript code, namespaces are not available and you cannot declare an interface or enumeration.
For more information on .NET enumerations, see “User-defined enumerations”.
Function calls on .NET primitive types and enumerations The pb2cs compiler merges functionality of .NET primitive types with the functionality of corresponding PowerBuilder primitive types. Function calls are also supported on .NET enumerated types that you import to a PowerBuilder .NET target.
For more information, see “Making function calls on .NET primitive and enumerated types”.
.NET index access You can access the indexes of .NET classes in the same way you access PowerBuilder array elements.
For more information, see “Accessing indexes for .NET classes”.
Function arguments defined as out parameters In .NET, functions can pass parameters using the “out” passing mode. Although there is no equivalent concept in PowerScript, you can access “out” parameters—as well as parameters passed by reference—using the “ref” keyword. .NET also allows you to overload a function that has a parameter passed by value with a prototype that differs only in the passing mode of the parameter. In these cases, if you want to call the function prototype with the parameter that uses the reference or out passing mode, you must use the ref keyword in your PowerScript call:
my_obj.TestMethod(ref l_string)