C# Type IsExplicitLayout

Description

Type IsExplicitLayout gets a value indicating whether the fields of the current type are laid out at explicitly specified offsets.

Syntax

Type.IsExplicitLayout has the following syntax.


public bool IsExplicitLayout { get; }

Example

The following example creates an instance of a type and displays the value of its IsExplicitLayout property. It uses the MySystemTime class.


//from   ww  w. j  a  va  2s .c  o  m
using System;
using System.Reflection;
using System.ComponentModel;
using System.Runtime.InteropServices;


[StructLayout(LayoutKind.Explicit, Size=16, CharSet=CharSet.Ansi)]
public class MySystemTime
{
   [FieldOffset(0)]public ushort wYear;
   [FieldOffset(1)]public ushort wMilliseconds;
}

public class Program
{
    public static void Main(string[] args)
    {
        Type  t = typeof(MySystemTime);
        Console.WriteLine(t.IsExplicitLayout);
    }
}

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