Type.IsExplicitLayout Property

July 28, 2014

Gets a value indicating whether the class layout attribute ExplicitLayout is selected for the Type.

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

public bool IsExplicitLayout { get; }

Property Value

Type: System.Boolean
true if the class layout attribute ExplicitLayout is selected for the Type; otherwise, false.

The LayoutMask is used to select the class layout attributes. The class layout attributes (AutoLayout, SequentialLayout and ExplicitLayout) define how the fields of the class instance are laid out in memory.

Classes marked with the ExplicitLayout attribute cause the loader to ignore field sequence and to use the explicit layout rules provided, in the form of field offsets, overall class size and alignment, or all of these.

Use the ExplicitLayout attribute to specify the offsets at which each field starts, or to specify the overall size and, optionally, the packing size of the objects of the class. The packing size is the empty memory space between fields and must be 1, 2, 4, 8 or 16 bytes.

If the current Type represents a constructed generic type, this property applies to the generic type definition from which the type was constructed. For example, if the current Type represents MyGenericType<int> (MyGenericType(Of Integer) in Visual Basic), the value of this property is determined by MyGenericType<T>.

If the current Type represents a type parameter in the definition of a generic type or generic method, this property always returns false.

The following example creates an instance of a type and displays the value of its IsExplicitLayout property. It uses the MySystemTime class, which is also in the code example for StructLayoutAttribute.

Windows Phone OS

Supported in: 8.1, 8.0

Show:
© 2014 Microsoft