Class StructLayoutAttribute
Lets you control the physical layout of the data fields of a class or structure in memory.
Inherited Members
Namespace: System.Runtime.InteropServices
Assembly: mscorlib.dll
Syntax
[AttributeUsage(AttributeTargets.Class|AttributeTargets.Struct, Inherited = false)]
public sealed class StructLayoutAttribute : Attribute
Constructors
StructLayoutAttribute(short)
Initalizes a new instance of the StructLayoutAttribute class with the specified System.Runtime.InteropServices.LayoutKind enumeration member.
Declaration
public StructLayoutAttribute(short layoutKind)
Parameters
Type | Name | Description |
---|---|---|
short | layoutKind | 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.
Declaration
public StructLayoutAttribute(LayoutKind layoutKind)
Parameters
Type | Name | Description |
---|---|---|
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.
Declaration
public CharSet CharSet
Field Value
Type | Description |
---|---|
CharSet |
Pack
Controls the alignment of data fields of a class or structure in memory.
Declaration
public int Pack
Field Value
Type | Description |
---|---|
int |
Size
Indicates the absolute size of the class or structure.
Declaration
public int Size
Field Value
Type | Description |
---|---|
int |
Properties
Value
Gets the LayoutKind value that specifies how the class or structure is arranged.
Declaration
public LayoutKind Value { get; }
Property Value
Type | Description |
---|---|
LayoutKind | One of the enumeration values that specifies how the class or structure is arranged. |