Example: Map an ABL array to a .NET array
- Last Updated: July 25, 2024
- 2 minute read
- OpenEdge
- Version 12.8
- Documentation
System.Drawing.Common assembly be noted in
assemblies.xml; it is not automatically available as it is with .NET
Framework.The following example shows how you might access a .NET one-dimensional array using an ABL array:
|
The .NET SetTabStops( ) method
takes a one-dimensional System.Single array as
its second INPUT parameter. The example passes
an ABL four-element array of DECIMAL values as
required by the implicit mapping to System.Single.
The
following example expands on the ABL array example in the previous section by invoking the StringFormat:GetTabStops( ) instance
method to return the tab stops that were previously set using the SetTabStops( ) method.
In this case, you do not need to explicitly create the .NET array
object, because the GetTabStops( ) method
returns one, as shown:
|
The example defines rTabsOut as
an array object of type "System.Single[]" corresponding
to the primitive data type array (C# float[]) that
the GetTabStops( ) method is defined to
return. Because the array is returned as the method's return type,
ABL does not automatically map it to an ABL DECIMAL array,
but to the specified array object. The code must therefore access
the array elements as objects also, and must individually convert
them to the ABL DECIMAL data type in order to work
with the element values. The ABL built-in UNBOX function
(see .NET boxing support) allows the example to extract the underlying mapped data type
from the .NET System.Object returned by the GetValue( ) method
for each array element. Note also the use of 1-based indexing for dTabsOut (the
ABL array) and 0-based indexing for rTabsOut (the .NET array).