System.Reflection.Emit.PackingSize Enumeration

Specifies one of two factors that determine the memory alignment of fields when a type is marshaled.

Syntax

[System.Runtime.InteropServices.ComVisible(true)]
public enum PackingSize

Remarks

Packing size affects the alignment of fields in structures and classes whose organization is System.Runtime.InteropServices.LayoutKind.Sequential. The packing size is one of two factors that determine the offset of a field when the structure or class is marshaled; the other factor is the effective size of the field. To determine the offset of a field:

[The 'ordered' type of list has not been implemented in the ECMA stylesheet.]
Note:

Once offsets have been computed for all the fields in the class or structure, padding is added so that the overall size is a multiple of the packing size.

For example, in a class containing a byte and a long, using packing size Size1, the offset of the byte field is zero (0) and the offset of the long field is one (1). If the packing size is Size4, the long field has offset four (4). In a class containing two short fields, using any packing size, the offset of the second short field is two (2).

Note:

Changing the packing size can affect performance if it causes fields to be aligned on offsets that are not multiples of their size.

Members

Member NameDescription
Size1

The packing size is 1 byte.

Size128

The packing size is 128 bytes.

Size16

The packing size is 16 bytes.

Size2

The packing size is 2 bytes.

Size32

The packing size is 32 bytes.

Size4

The packing size is 4 bytes.

Size64

The packing size is 64 bytes.

Size8

The packing size is 8 bytes.

Unspecified

The packing size is not specified.

Requirements

Namespace: System.Reflection.Emit
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0