Table of Contents

Class StructLayoutAttribute

Namespace
System.Runtime.InteropServices
Assembly
mscorlib.dll

Lets you control the physical layout of the data fields of a class or structure in memory.

[AttributeUsage(AttributeTargets.Class|AttributeTargets.Struct, Inherited = false)]
public sealed class StructLayoutAttribute : Attribute
Inheritance
StructLayoutAttribute
Inherited Members
Extension Methods

Constructors

StructLayoutAttribute(short)

Initalizes a new instance of the StructLayoutAttribute class with the specified System.Runtime.InteropServices.LayoutKind enumeration member.

public StructLayoutAttribute(short layoutKind)

Parameters

layoutKind short

A 16-bit integer that represents one of the LayoutKind values that specifes how the class or structure should be arranged.

StructLayoutAttribute(LayoutKind)

Initalizes a new instance of the StructLayoutAttribute class with the specified System.Runtime.InteropServices.LayoutKind enumeration member.

public StructLayoutAttribute(LayoutKind layoutKind)

Parameters

layoutKind LayoutKind

One of the enumeration values that specifes how the class or structure should be arranged.

Fields

CharSet

Indicates whether string data fields within the class should be marshaled as LPWSTR or LPSTR by default.

public CharSet CharSet

Field Value

CharSet

Pack

Controls the alignment of data fields of a class or structure in memory.

public int Pack

Field Value

int

Size

Indicates the absolute size of the class or structure.

public int Size

Field Value

int

Properties

Value

Gets the LayoutKind value that specifies how the class or structure is arranged.

public LayoutKind Value { get; }

Property Value

LayoutKind

One of the enumeration values that specifies how the class or structure is arranged.