C# Type IsLayoutSequential

Description

Type IsLayoutSequential gets a value indicating whether the fields of the current type are laid out sequentially, in the order that they were defined or emitted to the metadata.

Syntax

Type.IsLayoutSequential has the following syntax.


public bool IsLayoutSequential { get; }

Example

The following example creates an instance of a class for which the LayoutKind.Sequential enumeration value in the StructLayoutAttribute class has been set, checks for the IsLayoutSequential property, and displays the result.


using System;/*from  w  w  w.  j  a  v a 2  s .co  m*/
using System.Reflection;
using System.ComponentModel;
using System.Runtime.InteropServices;
class MyTypeSequential1
{
}
[StructLayoutAttribute(LayoutKind.Sequential)]
class MyTypeSequential2
{
    public static void Main(string []args)
    {
        try
        {
            MyTypeSequential1 myObj1 = new MyTypeSequential1();
            Type myTypeObj1 = myObj1.GetType();
            Console.WriteLine(myObj1.GetType().IsLayoutSequential);
        }
        catch(Exception e)
        {
            Console.WriteLine("\nAn exception occurred: {0}", e.Message);
        }
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version