NET 

.NET Predefined Native Types

COBOL provides predefined USAGES corresponding to many of the most commonly used .NET types. These names can be used in the USAGE phrase when declaring a data item, and anywhere that a classname is expected.

Predefined COBOL USAGE .NET Class C# equivalent Alternative COBOL
binary-char System.SByte sbyte PIC S9(2) COMP-5
binary-char unsigned System.Byte byte PIC 9(2) COMP-5
binary-short System.Int16 short PIC S9(4) COMP-5
binary-short unsigned System.UInt16 ushort PIC 9(4) COMP-5
binary-long System.Int32 int PIC S9(9) COMP-5
binary-long unsigned System.UInt32 uint PIC 9(9) COMP-5
binary-double System.Int64 long PIC S9(18) COMP-5
binary-double unsigned System.UInt64 ulong PIC 9(18) COMP-5
character System.Char char  
float-short System.Single float USAGE COMP-1
float-long System.Double double USAGE COMP-2
condition-value System.Boolean bool  
decimal System.Decimal decimal  
object System.Object object USAGE OBJECT REFERENCE
string System.String string  

Further .NET types can be specified in COBOL using the syntax USAGE class-name-1 or USAGE OBJECT REFERENCE class-name-1. All such data items and any of USAGE DECIMAL, OBJECT or STRING must be:


They may make use of Format 3 of the OCCURS clause in order to declare a .NET array.

Furthermore, in order to be mapped onto the corresponding .NET native type, any of the other predefined USAGEs listed above must also follow these rules.

Any COBOL data item that does not follow these rules, or is of any other category, is not considered to be a .NET native type and is allocated by the compiler with an internally managed byte array. COBOL pointer data items always point into one of these byte arrays.

.NET distinguishes two types of objects:


All value types can be turned into reference types by a process known as boxing. This happens automatically when needed, for example when a value type is passed as a parameter to a method that expects a System.Object as a parameter. It can be done explicitly by assigning a value type to an item of type System.Object (i.e. a generic object). Boxed value types can be unboxed to restore the original value type.

When you specify USAGE [OBJECT REFERNCE] class-name:


.NET arrays are defined with the format 3 OCCURS clause.