Assign between ABL primitive or array types and System.Object
- Last Updated: April 10, 2024
- 2 minute read
- OpenEdge
- Version 12.8
- Documentation
If you assign an ABL primitive type to a System.Object type
reference, ABL automatically boxes the ABL data type into the System.Object as
its default matching .NET object type. On the other hand,
if you assign a System.Object type reference that
represents a .NET mapped type to an ABL primitive type, ABL
automatically unboxes the mapped type to its corresponding ABL primitive
value, and attempts to assign that unboxed ABL value to the specified
ABL primitive type. For more information on boxing and unboxing,
see .NET boxing support. The same process works for passing ABL primitive types
to method INPUT parameters, but only for
parameters of .NET methods and constructors. For more information,
see Pass ABL data types to .NET constructor and method parameters.
Similar boxing and unboxing rules for assignment and parameter
passing apply between an ABL array and a System.Object type reference,
including the mapping of an ABL primitive array (such as an ABL INTEGER
EXTENT) to a .NET System.Object reference
that represents a .NET array of mapped type elements (such
as a "System.Int32[]"). In addition, ABL has rules
for boxing and unboxing during assignment and parameter passing
between an ABL array of any .NET object type and a compatible .NET array
object type reference. For more information on mapping between ABL
and .NET array types, see Access and use .NET arrays.
Note that when passing parameters to ABL routines (methods, constructors, procedures, and user-defined functions), ABL does no automatic boxing or unboxing. In such cases, ABL raises a compile-time error. To make these parameter passing cases work for ABL routines, you need to use the ABL BOX or UNBOX function, as appropriate. For more information, see Manual boxing.