Try OpenEdge Now
skip to main content
GUI for .NET Mapping Reference
Mapping Reference Entries : Explicit data type mapping from ABL primitive to .NET types
 

Explicit data type mapping from ABL primitive to .NET types

Sometimes, when you assign or pass an ABL primitive type to a .NET property or when you pass an ABL primitive type to a .NET method parameter, and more than one .NET type mapping is possible, you must explicitly indicate the mapping you want. You might also need to indicate the explicit .NET type when you assign (and box) an ABL primitive type to a System.Object or when you pass the ABL primitive as an argument to a System.Object or overloaded .NET method parameter. You must indicate explicit .NET data types when you define an ABL method or property in order to override a .NET method or implement a .NET interface (see the C# .NET code mapped to OpenEdge GUI for .NET ABL C# .NET code mapped to OpenEdge GUI for .NET ABL
For a .NET mapped type that is the default or only match for a given ABL data type, you only use the ABL data type to explicitly indicate the .NET type mapping. For all other .NET mapped types, ABL provides a special type keyword (ABL AS data type) that indicates the explicit .NET type mapping. The following table shows all the mappings between ABL and .NET primitive types as well as the AS data type keyword that you can use to indicate the explicit mapping to a .NET type other than the default match for the ABL primitive type.
Table 16. Explicit data type mapping from ABL primitive to .NET types
Explicit .NETobject type
Explicit C#primitive type
ABLprimitive type
ABLAS data type
System.Boolean
bool
LOGICAL
System.Byte
byte
INTEGER
UNSIGNED-BYTE
System.SByte
sbyte
INTEGER
BYTE
System.DateTime
DATETIME
System.Decimal
decimal
DECIMAL
System.Int16
short
INTEGER
SHORT
System.UInt16
ushort
INTEGER
UNSIGNED-SHORT
System.Int32
int
INTEGER
System.UInt32
uint
INT64
UNSIGNED-INTEGER
System.Int64
long
INT64
System.UInt64
ulong
DECIMAL
UNSIGNED-INT64
System.Double
double
DECIMAL
DOUBLE
System.Single
float
DECIMAL
FLOAT
System.Char
char
CHARACTER
SINGLE-CHARACTER
System.String
string
CHARACTER/ LONGCHAR
The following table shows examples of an explicit .NET type mapping using the AS data type keyword.
Table 17. Example explicit data type mappings using the AS data type keyword
Operation description
Operation with Type of data element
Assign an INTEGER as a System.Int16 value to a System.Object property or variable (creating a new System.Int16 object in the process).
System.Object = BOX( INTEGER, "SHORT").
Pass an INTEGER as a System.Int16 argument to the System.Object parameter of a .NET method (creating a new System.Int16 object in the process).
Method( INPUT INTEGER AS SHORT ).