Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
This topic has not yet been rated - Rate this topic

Type.IsLayoutSequential Property

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

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

public bool IsLayoutSequential { get; }
/** @property */
public final boolean get_IsLayoutSequential ()

public final function get IsLayoutSequential () : boolean

Property Value

true if the class layout attribute SequentialLayout 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.

For more information, see section 9.1.2 of the specification for the Common Language Infrastructure (CLI) documentation, "Partition II: Metadata Definition and Semantics". The documentation is available online at http://msdn.microsoft.com/net/ecma/ and http://www.ecma-international.org/publications/standards/Ecma-335.htm.

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 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.

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);
        }
    }
}

import System.*;
import System.Reflection.*;
import System.ComponentModel.*;
import System.Runtime.InteropServices.*;
class MyTypeSequential1
{
} //MyTypeSequential1

/** @attribute 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}.",
                System.Convert.ToString(myObj1.GetType().
                get_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}.",
                System.Convert.ToString(myObj2.GetType().
                get_IsLayoutSequential()));
        }
        catch (System.Exception e) {
            Console.WriteLine("\nAn exception occurred: {0}", e.get_Message());
        }
    } //main
} //MyTypeSequential2

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft. All rights reserved.