Data types
The following table lists the data type mappings between
PowerBuilder and .NET. Keep in mind that PowerBuilder and .NET data
types may not have the same definitions even if the type name is the
same or similar. For PowerBuilder data types, refer to the section called “Datatypes” in PowerScript Reference. For .NET
data types, refer to the Types
and variables web page.
PowerBuilder char maps to .NET string, and PowerBuilder ref char
maps to .NET char.
PowerBuilder blob[] maps to .NET byte[][]. PowerBuilder blob
two-dimensional array is unsupported.
The index in PowerScript starts from 1, while the index in .NET
starts from 0, therefore, PowerBuilder Array[1] maps to .NET
Array[0].
When the .NET function is imported to the NVO, the
two-dimensional array will be converted to Any data type when passed
as arguments or return values, and the first-dimensional array will be
converted to Any data type when passed as return values, because
PowerBuilder does not support using the array argument as the return
value of a function (the developer can use the corresponding array or
any to receive the value).
For numeric data type, the mapping between PowerBuilder and .NET
can be fuzzy. For example, even the .NET integer-type should be mapped
to PowerBuilder long-type normally, the .NET function “public int
Add(int parm1, int parm2)” can also be called by the integer-type
parameter in PowerBuilder (instead of the long-type parameter).
For standard data type and array data type, PowerBuilder can map
to the .NET nullable and non-nullable types, for example, PowerBuilder
integer type can map to the .NET short and short? types.
For numeric array, PowerBuilder and .NET must be exactly mapped.
For example, PowerBuilder integer-type array can only map to the .NET
short-type array.
Date and Time can only be used in arguments and cannot be used
in return values; when used in arguments, they are passed to .NET as
DateTime; when passed by Ref, the value will be sync to the Date and
Time variables; they cannot be used as return values to receive
DateTime return values from .NET; and cannot set or receive DateTime
property values from .NET.
When passing a PowerBuilder variable-length array to .NET, .NET
can use list to process the data from the PowerBuilder variable-length
array, and then assign the data to the PowerBuilder ref
variable-length array or return the data directly. At the end of this
section, there is a sample of PowerScript code that uses the
variable-length array to receive the double-type data from
.NET.
|
PowerBuilder |
C# |
Array (one and two |
Reference |
Generic |
|
int |
short |
Supported |
Supported |
Supported |
|
uint |
ushort |
Supported |
Supported |
Supported |
|
long |
int |
Supported |
Supported |
Supported |
|
longptr |
int32/int64 |
Supported |
Supported |
Supported |
|
ulong |
uint |
Supported |
Supported |
Supported |
|
longlong |
long/Int64 |
Supported |
Supported |
Supported |
|
boolean |
bool |
Supported |
Supported |
Supported |
|
char |
string/char |
Supported |
Supported |
Supported |
|
string |
string |
Supported |
Supported |
Unsupported |
|
real |
float |
Supported |
Supported |
Supported |
|
double |
double |
Supported |
Supported |
Supported |
|
decimal |
decimal |
Supported |
Supported |
Supported |
|
blob |
byte[] |
Supported |
Supported |
Supported |
|
Date |
DateTime |
Supported |
Supported |
Supported |
|
DateTime |
DateTime |
Supported |
Supported |
Supported |
|
Time |
DateTime |
Supported |
Supported |
Supported |
Supported return value data
types
The following table lists the return value data type mappings
between PowerBuilder and .NET.
|
PowerBuilder |
C# |
|
int |
short |
|
uint |
ushort |
|
long |
int |
|
longptr |
int32/int64 |
|
ulong |
uint |
|
longlong |
long/Int64 |
|
boolean |
bool |
|
char |
char |
|
string |
string |
|
real |
float |
|
double |
double |
|
decimal |
decimal |
|
blob |
byte[] |
|
DateTime |
DateTime |