Type.IsAutoLayout 속성

정의

현재 형식의 필드가 공용 언어 런타임에 의해 자동으로 배치되는지를 나타내는 값을 가져옵니다.

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

속성 값

Boolean

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

구현

예제

다음 예제에서는 형식의 인스턴스를 만들고 IsAutoLayout 속성을 표시합니다.

#using <System.dll>

using namespace System;
using namespace System::Reflection;
using namespace System::ComponentModel;
using namespace System::Runtime::InteropServices;

// The MyDemoAttribute class is selected as AutoLayout.

[StructLayoutAttribute(LayoutKind::Auto)]
public ref class MyDemoAttribute{};

void MyAutoLayoutMethod( String^ typeName )
{
   try
   {
      
      // Create an instance of the Type class using the GetType method.
      Type^ myType = Type::GetType( typeName );
      
      // Get and display the IsAutoLayout property of the
      // MyDemoAttribute instance.
      Console::WriteLine( "\nThe AutoLayout property for the MyDemoAttribute is {0}.", myType->IsAutoLayout );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "\nAn exception occurred: {0}.", e->Message );
   }

}

int main()
{
   MyAutoLayoutMethod( "MyDemoAttribute" );
}
using System;
using System.Runtime.InteropServices;

// The Demo class is attributed as AutoLayout.
[StructLayoutAttribute(LayoutKind.Auto)]
public class Demo
{
}

public class Example
{
    public static void Main()
    {
        // Create an instance of the Type class using the GetType method.
        Type  myType=typeof(Demo);
        // Get and display the IsAutoLayout property of the
        // Demoinstance.
        Console.WriteLine("\nThe AutoLayout property for the Demo class is {0}.",
            myType.IsAutoLayout);
    }
}
Imports System.Runtime.InteropServices

' The Demo class is has the AutoLayout attribute.
<StructLayoutAttribute(LayoutKind.Auto)> _
Public Class Demo
End Class 

Public Class Example
    Public Shared Sub Main()
        ' Get the Type object for the Demo class.
        Dim myType As Type = GetType(Demo)
        ' Get and display the IsAutoLayout property of the 
        ' Demo class.
        Console.WriteLine("The AutoLayout property for the Demo class is '{0}'.", _
            myType.IsAutoLayout.ToString())
    End Sub 
End Class

설명

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

동적 형식의 경우 형식을 만들 때 지정할 수 TypeAttributes.AutoLayout 있습니다. 코드에서 StructLayoutAttribute 열거형 값이 있는 특성을 LayoutKind.Auto 형식에 적용하여 런타임에서 클래스를 레이아웃하는 적절한 방법을 결정할 수 있도록 합니다.

참고

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

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

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

적용 대상

추가 정보