No, MarshalAs cannot be used to do bitfields. You have to do the bit
twiddling yourself to set and get the bitfield. It's easiest to
encapsulate it inside a property.

-----Original Message-----
From: Chris Szurgot [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, August 08, 2002 2:36 PM
To: [EMAIL PROTECTED]
Subject: [ADVANCED-DOTNET] MarshalAs on bit boundaries

I'm trying to do some interop with Win32 Comm handling, and at least one
of the structures has fields that align on bit boundaries. Is there a
way to do this in StructLayout.Explicit? I've been able to fake it out a
little by using a [Flags] enum, but that doesn't work in the case of a
two bit field.

Many thanks, Chris

You can read messages from the Advanced DOTNET archive, unsubscribe from
Advanced DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to