While data type marshaling is necessarily platform-specific, this Standard specifies a minimum set of data types that shall be supported by all conforming implementations of the CLI. Additional data types can be supported in a platform-specific manner, using custom attributes and/or custom modifiers to specify any special handling required on the particular implementation.
The following data types shall be marshaled by all conforming implementations of the CLI; the native data type to which they conform is implementation-specific:
-
All integer data types (int8, int16, unsigned int8, bool, char, etc.) including the native integer types.
-
Enumerations, as their underlying data type.
-
All floating-point data types (float32 and float64), if they are supported by the CLI implementation for managed code.
-
The type string.
-
Unmanaged pointers to any of the above types.
In addition, the following types shall be supported for marshaling from managed code to unmanaged code, but need not be supported in the reverse direction (i.e., as return types when calling unmanaged methods or as parameters when calling from unmanaged methods into managed methods):
-
One-dimensional zero-based arrays of any of the above
-
Delegates (the mechanism for calling from unmanaged code into a delegate is platform-specific; it should not be assumed that marshaling a delegate will produce a function pointer that can be used directly from unmanaged code).
Finally, the type System.Runtime.InteropServices.GCHandle
can be used to marshal an object to unmanaged code. The unmanaged code receives a platform-specific data type that can be used as an "opaque handle" to a specific object. See Partition IV.