Try OpenEdge Now
skip to main content
GUI for .NET Programming
Using .NET data types in ABL : Assigning between ABL primitive or array types and System.Object
 

Assigning between ABL primitive or array types and System.Object

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 boxingsupport. 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 Passing 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 Accessingand using .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.