Typically the runtime controls the physical layout of the data members of class. The StructLayoutAttribute allows the user to control the physical layout of the data members of a class. Explicit control of a classes layout is important if the class is to be passed to unmanaged code that expects a specific layout. The LayoutKind value Sequential is used to force the members to be laid out sequentially in the order they appear. Explicit is used to control the precise position of each data member. With Explicit each member must use the FieldOffsetAttribute to indicate the position of that field within the type.
Object
Attribute
StructLayoutAttribute
[Visual Basic] Public Class StructLayoutAttribute Inherits Attribute [C#] public class StructLayoutAttribute : Attribute [C++] public __gc class StructLayoutAttribute : public Attribute [JScript] public class StructLayoutAttribute extends Attribute
Can be used to attribute classes or structures.
Namespace: System.Runtime.InteropServices
Assembly: mscorlib.dll
StructLayoutAttribute Members | System.Runtime.InteropServices Namespace