Export (0) Print
Expand All

Default Marshaling for Boolean Types

In general, marshaling base data types is straightforward. The Boolean data type is an exception. You can apply the MarshalAsAttribute attribute to marshal the Boolean type to any of the representations shown in the following table.

Enumeration typeDescription of unmanaged format
UnmanagedType.Bool 4-byte integer value where any nonzero value represents TRUE and 0 represents FALSE. This is the default format of a Boolean field in a structure.
UnmanagedType.U11-byte integer value where the value 1 represents TRUE and 0 represents FALSE.
UnmanagedType.VariantBool2-byte integer value where the value -1 represents TRUE and 0 represents FALSE. This is the default format of a Boolean parameter.

See Also

Default Marshaling Behavior | Blittable and Non-Blittable Types | Directional Attributes | Copying and Pinning

Show:
© 2014 Microsoft