Type.IsLayoutSequential Property
Gets a value indicating whether the class layout attribute SequentialLayout is selected for the Type.
[Visual Basic] Public ReadOnly Property IsLayoutSequential As Boolean [C#] public bool IsLayoutSequential {get;} [C++] public: __property bool get_IsLayoutSequential(); [JScript] public function get IsLayoutSequential() : Boolean;
Property Value
true if the class layout attribute SequentialLayout is selected for the Type; otherwise, false.
Remarks
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.
For more information, see section 9.1.2 of the specification for the Common Language Infrastructure, Partition II, located in the Tool Developers Guide directory installed with the .NET Framework SDK.
Example
[Visual Basic, C#, C++] The following example creates an instance of a class for which the Sequential member of the LayoutKind enum in the StructLayoutAttribute class has been set, checks for the property IsLayoutSequential, and displays the result.
[Visual Basic] Imports System Imports System.Reflection Imports System.ComponentModel Imports System.Runtime.InteropServices Imports Microsoft.VisualBasic Class MyTypeSequential1 End Class 'MyTypeSequential1 <StructLayoutAttribute(LayoutKind.Sequential)> Class MyTypeSequential2 Public Shared Sub Main() Try ' Create an instance of MyTypeSequential1. Dim myObj1 As New MyTypeSequential1() Dim myTypeObj1 As Type = myObj1.GetType() ' Check for and display the SequentialLayout attribute. Console.WriteLine(ControlChars.Cr + "The object myObj1 has IsLayoutSequential: {0}.", myObj1.GetType().IsLayoutSequential.ToString()) ' Create an instance of MyTypeSequential2. Dim myObj2 As New MyTypeSequential2() Dim myTypeObj2 As Type = myObj2.GetType() ' Check for and display the SequentialLayout attribute. Console.WriteLine(ControlChars.Cr + "The object myObj2 has IsLayoutSequential: {0}.", myObj2.GetType().IsLayoutSequential.ToString()) Catch e As Exception Console.WriteLine(ControlChars.Cr + "An exception occurred: {0}", e.Message.ToString()) End Try End Sub 'Main End Class 'MyTypeSeq2 [C#] using System; using System.Reflection; using System.ComponentModel; using System.Runtime.InteropServices; class MyTypeSequential1 { } [StructLayoutAttribute(LayoutKind.Sequential)] class MyTypeSequential2 { public static void Main(string []args) { try { // Create an instance of myTypeSeq1. MyTypeSequential1 myObj1 = new MyTypeSequential1(); Type myTypeObj1 = myObj1.GetType(); // Check for and display the SequentialLayout attribute. Console.WriteLine("\nThe object myObj1 has IsLayoutSequential: {0}.", myObj1.GetType().IsLayoutSequential); // Create an instance of 'myTypeSeq2' class. MyTypeSequential2 myObj2 = new MyTypeSequential2(); Type myTypeObj2 = myObj2.GetType(); // Check for and display the SequentialLayout attribute. Console.WriteLine("\nThe object myObj2 has IsLayoutSequential: {0}.", myObj2.GetType().IsLayoutSequential); } catch(Exception e) { Console.WriteLine("\nAn exception occurred: {0}", e.Message); } } } [C++] #using <mscorlib.dll> #using <System.dll> using namespace System; using namespace System::Reflection; using namespace System::ComponentModel; using namespace System::Runtime::InteropServices; __gc class MyTypeSequential1 { }; [StructLayoutAttribute(LayoutKind::Sequential)] __gc class MyTypeSequential2 { }; int main() { try { // Create an instance of myTypeSeq1. MyTypeSequential1* myObj1 = new MyTypeSequential1(); // Check for and display the SequentialLayout attribute. Console::WriteLine(S"\nThe object myObj1 has IsLayoutSequential: {0}.", __box(myObj1->GetType()->IsLayoutSequential)); // Create an instance of 'myTypeSeq2' class. MyTypeSequential2* myObj2 = new MyTypeSequential2(); // Check for and display the SequentialLayout attribute. Console::WriteLine(S"\nThe object myObj2 has IsLayoutSequential: {0}.", __box(myObj2->GetType()->IsLayoutSequential)); } catch (Exception* e) { Console::WriteLine(S"\nAn exception occurred: {0}", e->Message); } }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Common Language Infrastructure (CLI) Standard
See Also
Type Class | Type Members | System Namespace | TypeAttributes | IsAutoLayout | IsExplicitLayout | Metadata Overview