Passing Data as Parameters

The .NET CLR is type-sensitive and generates or throws an error if an exact match on a data type does not occur. At run time, ACUCOBOL-GT attempts to convert data types to the format expected by the CLR. For the best possible results, when passing data as parameters to .NET functions, use the table below to determine what parameter to pass.

For example, when the COPY file says "int", pass "SIGNED-INT" for the parameter type in your COBOL program. The ACUCOBOL-GT runtime converts this to "System.Int32" before passing it to the .NET assembly. The "int", "SIGNED-INT", and "System32.Int32" parameters all represent a 4-byte field holding signed binary data. The runtime also converts PIC s999 to a SIGNED-INT field.

COPY File Parameter Parameter to Pass Converted to .NET
BSTR - TYPE 8 PIC X(n) System.String
int - TYPE 3 SIGNED-INT System.Int32
unsigned int - TYPE 19 UNSIGNED-INT System.UInt32
single - TYPE 4 FLOAT System.Single
double - TYPE 5 DOUBLE System.Double
short - TYPE 2 SIGNED-SHORT System.Int16
unsigned short - TYPE 18 UNSIGNED-SHORT System.UInt16
unsigned char - TYPE 17 PIC X System.Byte

Be aware that the compiler does not always know which method declaration to use when methods are overloaded. In your COBOL program, be sure to use COBOL types that match the COPY file method declaration.