Implicit data type mappings

The following table shows the implicit mappings between .NET mapped data types and ABL primitive types. These .NET mapped data types are shown in two forms—as object types and as C# primitive data types. .NET has more mapped data types than the ABL has primitive types. So, more than one .NET type often maps to a single ABL primitive type. Where an exact mapping is not possible, ABL uses the primitive type that most completely holds the value. For these cases, and a few others, run-time errors can result if a provided value does not fit into the destination data type. Entries in the table have footnotes to indicate where any special conditions can or do occur. For more information on these conditions, see the sections following the table.

Note also that ABL supports similar implicit mappings between ABL primitive arrays and .NET arrays of mapped data types. For more information, see Implicit array mappings.

Table 1. Implicit mappings between .NET and ABL data types
Implicit .NETobject type Implicit C#primitive data type Implicit ABLprimitive type
System.Boolean bool LOGICAL
System.Byte byte INTEGER1,2
System.SByte sbyte INTEGER1
System.DateTime DATETIME
System.Decimal decimal DECIMAL3,4
System.Int16 short INTEGER1
System.UInt16 ushort INTEGER1,2
System.Int32 int INTEGER4
System.UInt32 uint INT645,2
System.Int64 long INT644
System.UInt64 ulong DECIMAL2,6
System.Double double DECIMAL7
System.Single float DECIMAL7
System.Char char CHARACTER8
System.String string CHARACTER4

LONGCHAR9

1 An ABL INTEGER is a 32-bit number. Thus, it can hold values that are too big to store in a .NET System.Byte, System.SByte, System.Int16, or System.UInt16. Therefore, AVM raises a run-time error if an incompatible value is assigned.
2 If you pass a negative ABL data type to an unsigned data type, the ABL virtual machine (AVM) raises a run-time error.
3 The range of values for a .NET System.Decimal and the range of values for an ABL DECIMAL are not equivalent. In particular, an ABL DECIMAL can be a much larger positive number or a much smaller negative number than a .NET System.Decimal can represent, and a .NET System.Decimal can represent a positive or negative number with much higher precision (with more significant digits to the right of the decimal point) than an ABL DECIMAL can represent. Therefore, the AVM raises a run-time error if you assign too large or too small of an ABL DECIMAL value to a .NET System.Decimal. If you assign too precise a .NET System.Decimal to an ABL DECIMAL, with too many significant digits to the right of the decimal point, ABL truncates the least significant digits necessary to represent the value as an ABL DECIMAL.
4 If you specify this ABL data type for a parameter of an overloaded .NET method and some overloads are distinguished by multiple .NET data types that match this same ABL data type, ABL automatically maps the corresponding .NET data type as the default match for the specified ABL data type. For example, if the method is overloaded by a parameter for both System.Decimal and System.Double, ABL automatically maps a specified ABL DECIMAL to System.Decimal, unless you indicate otherwise. For information on indicating a particular .NET data type mapping for a given ABL data type, see Indicate explicit .NET data types.
5 An ABL INT64 is a 64-bit number. Thus, it can hold values that are too big to store in a .NET System.UInt32. Therefore, AVM raises a run-time error if an incompatible value is assigned.
6 An ABL DECIMAL can represent a much larger number than a System.UInt64. Therefore, AVM raises a run-time error if an incompatible value is assigned.
7 An ABL DECIMAL represents numbers up to 50 digits long. As a result, an ABL DECIMAL value cannot represent the full range of values for a .NET System.Double or System.Single. Therefore, AVM raises a run-time error if an incompatible value is assigned. Also, an ABL DECIMAL can lose precision when it is represented by a .NET System.Double or System.Single.
8 This ABL CHARACTER mapping supports a single Unicode character.
9 When the value comes from .NET, ABL converts from System.String to either CHARACTER or LONGCHAR, depending on the length of the character string. When the value comes from ABL, System.String accepts values from either CHARACTER or LONGCHAR.