Gets a value indicating whether the class layout attribute ExplicitLayout is selected for the Type.
Assembly: mscorlib (in mscorlib.dll)
Public ReadOnly Property IsExplicitLayout As Boolean
public bool IsExplicitLayout { get; }
public: virtual property bool IsExplicitLayout { bool get () sealed; }
abstract IsExplicitLayout : bool override IsExplicitLayout : bool
Property Value
Type: System.Booleantrue if the class layout attribute ExplicitLayout is selected for the Type; otherwise, false.
Implements
_Type.IsExplicitLayoutThe 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.
Imports System Imports System.Reflection Imports System.ComponentModel Imports System.Runtime.InteropServices Imports Microsoft.VisualBasic 'Class to test for the ExplicitLayout property. <StructLayout(LayoutKind.Explicit, Size := 16, CharSet := CharSet.Ansi)> _ Public Class MySystemTime <FieldOffset(0)> Public wYear As Short <FieldOffset(2)> Public wMonth As Short <FieldOffset(4)> Public wDayOfWeek As Short <FieldOffset(6)> Public wDay As Short <FieldOffset(8)> Public wHour As Short <FieldOffset(10)> Public wMinute As Short <FieldOffset(12)> Public wSecond As Short <FieldOffset(14)> Public wMilliseconds As Short End Class Public Class Program Public Shared Sub Main() 'Create an instance of type using the GetType method. Dim t As Type = GetType(MySystemTime) ' Get and display the IsExplicitLayout property. Console.WriteLine(vbCrLf & "IsExplicitLayout for MySystemTime is {0}.", _ t.IsExplicitLayout) End Sub End Class
using System; using System.Reflection; using System.ComponentModel; using System.Runtime.InteropServices; // Class to test for the ExplicitLayout property. [StructLayout(LayoutKind.Explicit, Size=16, CharSet=CharSet.Ansi)] public class MySystemTime { [FieldOffset(0)]public ushort wYear; [FieldOffset(2)]public ushort wMonth; [FieldOffset(4)]public ushort wDayOfWeek; [FieldOffset(6)]public ushort wDay; [FieldOffset(8)]public ushort wHour; [FieldOffset(10)]public ushort wMinute; [FieldOffset(12)]public ushort wSecond; [FieldOffset(14)]public ushort wMilliseconds; } public class Program { public static void Main(string[] args) { // Create an instance of the type using the GetType method. Type t = typeof(MySystemTime); // Get and display the IsExplicitLayout property. Console.WriteLine("\nIsExplicitLayout for MySystemTime is {0}.", t.IsExplicitLayout); } }
.NET Framework
Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0.NET Framework Client Profile
Supported in: 4, 3.5 SP1Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.