C# TypeInfo IsLayoutSequential
Description
TypeInfo 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
TypeInfo.IsLayoutSequential
has the following syntax.
public bool IsLayoutSequential { get; }
Example
using System;//from w w w . jav a 2 s . c o m
using System.Reflection;
using System.ComponentModel;
using System.Runtime.InteropServices;
class MyTypeSequential1
{
}
[StructLayoutAttribute(LayoutKind.Sequential)]
class MyTypeSequential2
{
public static void Main(string []args)
{
MyTypeSequential1 myObj1 = new MyTypeSequential1();
Type myTypeObj1 = myObj1.GetType();
Console.WriteLine("\nThe object myObj1 has IsLayoutSequential: {0}.", myObj1.GetType().IsLayoutSequential);
MyTypeSequential2 myObj2 = new MyTypeSequential2();
Type myTypeObj2 = myObj2.GetType();
Console.WriteLine("\nThe object myObj2 has IsLayoutSequential: {0}.", myObj2.GetType().IsLayoutSequential);
}
}
The code above generates the following result.