Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

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 type

Description 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 and of a Boolean parameter in platform invoke calls.

UnmanagedType.U1

1-byte integer value where the value 1 represents true and 0 represents false.

UnmanagedType.VariantBool

2-byte integer value where the value -1 represents true and 0 represents false. This is the default format of a Boolean parameter in COM calls.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.