Share via


StructLayoutAttribute Class

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

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

Inheritance Hierarchy

System. . :: . .Object
  System. . :: . .Attribute
    System.Runtime.InteropServices..::..StructLayoutAttribute

Namespace:  System.Runtime.InteropServices
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
<AttributeUsageAttribute(AttributeTargets.Class Or AttributeTargets.Struct, Inherited := False)> _
Public NotInheritable Class StructLayoutAttribute _
    Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Struct, Inherited = false)]
public sealed class StructLayoutAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class|AttributeTargets::Struct, Inherited = false)]
public ref class StructLayoutAttribute sealed : public Attribute
[<Sealed>]
[<AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Struct, Inherited = false)>]
type StructLayoutAttribute =  
    class
        inherit Attribute
    end
public final class StructLayoutAttribute extends Attribute

The StructLayoutAttribute type exposes the following members.

Constructors

  Name Description
Public method StructLayoutAttribute(Int16) Initalizes a new instance of the StructLayoutAttribute class with the specified System.Runtime.InteropServices..::..LayoutKind enumeration member.
Public method StructLayoutAttribute(LayoutKind) Initalizes a new instance of the StructLayoutAttribute class with the specified System.Runtime.InteropServices..::..LayoutKind enumeration member.

Top

Properties

  Name Description
Public property Value Gets the LayoutKind value that specifies how the class or structure is arranged.

Top

Methods

  Name Description
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Fields

  Name Description
Public field CharSet Indicates whether string data fields within the class should be marshaled as LPWSTR or LPSTR by default.
Public field Pack Controls the alignment of data fields of a class or structure in memory.
Public field Size Indicates the absolute size of the class or structure.

Top

Remarks

You can apply this attribute to classes or structures.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

System.Runtime.InteropServices Namespace