Targeted Memory Assignment for Structure Members with the Attributes StructLayout and FieldOffset

Structures permit a targeted placement of memory areas for field variables. It’s important to mark the structure with a special attribute and thus instruct the compiler how to overlap the memory areas of the various field variables.

This possibility makes working with the different byte significance of integer values very easy. Integer numbers are composed of bytes, as you know. A number of the data type Short is stored in 2 bytes, an Integer in 4 bytes, and a Long in 8 bytes. For signed integer values, the highest bit is used as the sign. If that bit is set, the value is negative; otherwise, it is positive. It is relatively labor-intensive to extract ...

Get Microsoft® Visual Basic® 2010 Developer’s Handbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.