Partager via


.NET Compact Framework Blittable Types 

A type is considered blittable if it has a common representation in both managed and unmanaged memory, thereby requiring no special handling by the marshaler to convert to unmanaged or managed code.

Blittable Types in Both Frameworks

The following types, defined in the System namespace, are blittable types in both the full .NET Framework and .NET Compact Framework:

The following complex types are also blittable:

  • One-dimensional arrays of blittable types.

  • Formatted value types that contain only blittable types. Because all structures and classes always have sequential layout in the .NET Compact Framework, the managed value type has the same memory layout as the unmanaged structure.

Blittable Types Only in the .NET Compact Framework

The .NET Compact Framework provides the following blittable types because of their implementation in the common language runtime:

  • Boolean

    This is a 1-byte integer value. In the full .NET Framework, the default marshaling for a Boolean corresponds to the MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool) attribute, which uses a 4-byte integer value.

  • Char

    This is always a Unicode char (2 bytes), whereas the full .NET Framework may treat this either as a Unicode char or an ANSI char depending on the MarshalAsAttribute attribute or the System.Runtime.InteropServices.DllImportAttribute.CharSet field.

  • String

    This is always treated as a Unicode array, whereas the .NET Framework may treat this as a Unicode or ANSI array or a BSTR depending on the MarshalAsAttribute attribute or the System.Runtime.InteropServices.DllImportAttribute.CharSet field.

See Also

Other Resources

Marshaling Support