Type Compatibility in Interoperation with Managed Code

For COBOL to interoperate with managed code in other languages, the COBOL must use data types that are compatible with those languages. Often there is not a strict one-to-one correspondence between types in different languages and so you need to manipulate the code to ensure compatibility.

The Microsoft Common Language Specification (CLS) defines a set of basic language features, including the rules for the common type system. In theory, your COBOL must use CLS-compliant types. However, in practice, you can use .NET types that are not CLS-compliant, providing the non-COBOL language supports them. This is true of many C# types.

Some ISO 2002 (or more precisely ISO/IEC 1989:2002) data types, such as binary-long and float-short are available, and we recommend you use these where appropriate. See COBOL Type Compatibility for details.

The techniques for ensuring data type compatibility include the following: