Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

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.

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.

See Also

Community Additions

ADD
Show:
© 2015 Microsoft