Type.IsExplicitLayout 속성

정의

현재 형식의 필드가 명시적으로 지정된 오프셋에 배치되는지를 나타내는 값을 가져옵니다.

public:
 property bool IsExplicitLayout { bool get(); };
public bool IsExplicitLayout { get; }
member this.IsExplicitLayout : bool
Public ReadOnly Property IsExplicitLayout As Boolean

속성 값

Boolean

현재 형식의 true 속성에 Attributes이 포함되어 있으면 ExplicitLayout이고, 그렇지 않으면 false입니다.

구현

예제

다음 예제에서는 형식의 인스턴스를 만들고 해당 속성의 값을 IsExplicitLayout 표시합니다. 에 MySystemTime 대한 코드 예제에도 있는 클래스를 StructLayoutAttribute 사용합니다.

using System;
using System.Reflection;
using System.ComponentModel;
using System.Runtime.InteropServices;

// Class to test for the ExplicitLayout property.
[StructLayout(LayoutKind.Explicit, Size=16, CharSet=CharSet.Ansi)]
public class MySystemTime
{
   [FieldOffset(0)]public ushort wYear;
   [FieldOffset(2)]public ushort wMonth;
   [FieldOffset(4)]public ushort wDayOfWeek;
   [FieldOffset(6)]public ushort wDay;
   [FieldOffset(8)]public ushort wHour;
   [FieldOffset(10)]public ushort wMinute;
   [FieldOffset(12)]public ushort wSecond;
   [FieldOffset(14)]public ushort wMilliseconds;
}

public class Program
{
    public static void Main(string[] args)
    {
        // Create an instance of the type using the GetType method.
        Type  t = typeof(MySystemTime);
        // Get and display the IsExplicitLayout property.
        Console.WriteLine("\nIsExplicitLayout for MySystemTime is {0}.",
            t.IsExplicitLayout);
    }
}
Imports System.Reflection
Imports System.ComponentModel
Imports System.Runtime.InteropServices

'Class to test for the ExplicitLayout property.
   <StructLayout(LayoutKind.Explicit, Size := 16, CharSet := CharSet.Ansi)>  _
   Public Class MySystemTime
      <FieldOffset(0)> Public wYear As Short
      <FieldOffset(2)> Public wMonth As Short
      <FieldOffset(4)> Public wDayOfWeek As Short
      <FieldOffset(6)> Public wDay As Short
      <FieldOffset(8)> Public wHour As Short
      <FieldOffset(10)> Public wMinute As Short
      <FieldOffset(12)> Public wSecond As Short
      <FieldOffset(14)> Public wMilliseconds As Short
   End Class 

Public Class Program
    Public Shared Sub Main()
        'Create an instance of type using the GetType method.
        Dim t As Type = GetType(MySystemTime)
        ' Get and display the IsExplicitLayout property.
        Console.WriteLine(vbCrLf & "IsExplicitLayout for MySystemTime is {0}.", _
            t.IsExplicitLayout)
    End Sub
End Class

설명

이 속성은 편의상 제공됩니다. 또는 TypeAttributes.LayoutMask 열거형 값을 사용하여 형식 레이아웃 특성을 선택한 다음 가 설정되었는지 테스트할 수 TypeAttributes.ExplicitLayout 있습니다. TypeAttributes.AutoLayout, TypeAttributes.ExplicitLayoutTypeAttributes.SequentialLayout 열거형 값은 형식의 필드가 메모리에 배치되는 방식을 나타냅니다.

동적 형식의 경우 형식을 만들 때 지정할 수 TypeAttributes.ExplicitLayout 있습니다. 코드에서 StructLayoutAttribute 열거형 값을 가진 특성을 LayoutKind.Explicit 형식에 적용하여 필드가 시작되는 오프셋을 명시적으로 지정하도록 지정합니다.

참고

메서드를 사용하여 가 GetCustomAttributes 형식에 적용되었는지 여부를 확인할 수 StructLayoutAttribute 없습니다.

현재 가 Type 구성된 제네릭 형식을 나타내는 경우 이 속성은 형식이 생성되는 제네릭 형식 정의에 적용됩니다. 예를 들어 현재 TypeMyGenericType<int> (Visual Basic)를 나타내는 경우 MyGenericType(Of Integer) 이 속성의 값은 에 의해 MyGenericType<T> 결정됩니다.

현재 가 Type 제네릭 형식 또는 제네릭 메서드 정의에서 형식 매개 변수를 나타내는 경우 이 속성은 항상 false 를 반환합니다.

적용 대상

추가 정보