Try OpenEdge Now
skip to main content
GUI for .NET Programming
Accessing and Managing .NET Classes from ABL : Accessing .NET class members : Specifying .NET constructor and method parameters

Specifying .NET constructor and method parameters

ABL supports calls to .NET constructors and methods in much the same way as it does for ABL constructors and methods. However, you must identify the syntax for passing a .NET constructor or method parameter from one of the following sources:
*Interpret the ABL parameter passing syntax from the corresponding parameter as specified for the constructor or method signature in the .NET documentation for the method. The .NET documentation typically provides method signatures in two or more of the supported CLS-compliant languages.
*Interpret the ABL parameter passing syntax from the signature for the method displayed using the Class Browser view of the Progress Developer Studio for OpenEdge. This Class Browser allows you to view all .NET method signatures using an extended form of ABL parameter definition syntax. ABL documentation also uses this syntax to document the public methods provided by OpenEdge .NET classes. For more information, see the introduction to the Class Properties and Methods Reference (.NET Objects) section in OpenEdge Development: ABL Reference.
This section provides guidelines for identifying these parameter options. To help with this, ABL also provides extended syntax to disambiguate .NET parameter data types of overloaded method parameters, all of which map to the same ABL data type.
This is the general syntax for a parameter list that you pass to a class constructor that you invoke using the NEW function (classes) or that you pass to a method that you call:


( parameter[ , parameter]... )
For a .NET class constructor or method you can specify each parameter using the following parameter passing syntax:


[ INPUT | OUTPUT | INPUT-OUTPUT ]parm[ AS data-type]
Note: You can use the same syntax for passing .NET parameters that you define for ABL routines, including ABL methods, procedures, and user-defined functions.
A parm is the data that you pass as a parameter, which can take one of several possible forms—for example, a literal value, expression, or variable—any ABL element supported for parameter passing that provides or can hold a value. To identify the parameter mode (INPUT, OUTPUT or INPUT-OUTPUT) and the form of data that you can specify for parm, you have to know the .NET parameter mode and data type of the corresponding constructor or method parameter. For a Microsoft .NET constructor or method, you can locate this information for each constructor and method in the .NET Framework class library documentation, where the parameter mode, and often the data type, is indicated using language-specific syntax.
The following table shows how to determine the ABL parameter mode from the keyword used to specify the equivalent parameter mode in C#.
Table 1. C# syntax matching ABL parameter modes
ABL parameter mode
Corresponding C# syntax
INPUT parm
out parm
ref parm
Note that in C#, the default (no keyword) corresponds to the ABL INPUT mode. Therefore, you cannot pass a literal value or an expression to a parameter whose C# mode is specified by out or ref.
As for any ABL method parameter, you must pass parm as a data type that matches the data type of a given .NET constructor or method parameter. For all .NET object types, except for a small subset briefly described in the following paragraph, you must pass a compatible .NET object type, similar to how you pass an ABL user-defined class or interface type as an ABL method parameter.
A small subset of .NET object types correspond and map to .NET language primitive data types, such as the C# int, float, or string. Both the .NET primitive types and their corresponding object types are referred to, in ABL documentation, as .NET mapped data types. For each of these .NET mapped types (whether it is the primitive or object equivalent), you must pass a corresponding ABL built-in primitive type. ABL supports implicit mappings between ABL built-in primitive types and all .NET mapped data types. ABL also supports widening relationships that allow multiple ABL primitive types to be passed as certain .NET mapped data types.
Because ABL has fewer primitive types than .NET has mapped data types, the implicit mappings include a few ABL primitive types that match multiple .NET mapped data types. In order to support .NET constructor and method overloading, the parameter passing syntax includes the AS option where you can specify a keyword (data-type) that corresponds to a particular .NET mapped data type. In this way, you can allow ABL to identify the specific overloading when more than one .NET data type in the overloading for a parameter maps to the ABL primitive type of the argument you are passing.
Note: This parameter-passing AS option is essentially the same as the AS option for passing parameters to COM object methods. For more information, see the Accessing COM object properties and methods section in OpenEdge Development: ABL Reference.
.NET also supports constructors and methods with a variable number of parameters. The parameters in this variable list are always of the same .NET data type. In ABL, you can pass the variable parameters in a single-dimensional array as the final parameter (parm) to the constructor or method. You can typically call a method that takes variable parameters multiple times, varying the number of elements in the array with each call according to the number of variable parameters that you want to pass. In .NET documentation, the C# signature for a method that defines variable parameters specifies the keyword param at the position of the variable parameter (again, always as the last parameter), followed by the data type of the parameter array.
Note: In some .NET languages, you can provide the elements of the variable parameter array as individual parameters to the constructor or method call. However, in ABL you can only pass variable parameters in a single array parameter.
For more information on data types for parameter passing, including the implicit data type mappings, the available keywords to indicate explicit .NET data type mappings using the AS option, widening options, and using arrays with .NET, see Using .NET data types in ABL and Passing ABL data types to .NET constructor and method parameters. For reference information on passing .NET constructor and method parameters, see the Parameter passing syntax reference entry in OpenEdge Development: ABL Reference.