Type.IsLayoutSequential 속성

정의

메타데이터에 정의되고 내보낸 순서로 현재 형식의 필드가 순차적으로 배치되는지를 나타내는 값을 가져옵니다.

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

속성 값

Boolean

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

구현

예제

다음 예제에서는 클래스의 열거형 값이 설정된 클래스의 인스턴스를 만들고 LayoutKind.Sequential 속성을 확인하고 결과를 StructLayoutAttribute IsLayoutSequential 표시합니다.

#using <System.dll>

using namespace System;
using namespace System::Reflection;
using namespace System::ComponentModel;
using namespace System::Runtime::InteropServices;
ref class MyTypeSequential1{};


[StructLayoutAttribute(LayoutKind::Sequential)]
ref class MyTypeSequential2{};

int main()
{
   try
   {
      
      // Create an instance of myTypeSeq1.
      MyTypeSequential1^ myObj1 = gcnew MyTypeSequential1;
      
      // Check for and display the SequentialLayout attribute.
      Console::WriteLine( "\nThe object myObj1 has IsLayoutSequential: {0}.", myObj1->GetType()->IsLayoutSequential );
      
      // Create an instance of 'myTypeSeq2' class.
      MyTypeSequential2^ myObj2 = gcnew MyTypeSequential2;
      
      // Check for and display the SequentialLayout attribute.
      Console::WriteLine( "\nThe object myObj2 has IsLayoutSequential: {0}.", myObj2->GetType()->IsLayoutSequential );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "\nAn exception occurred: {0}", e->Message );
   }

}
using System;
using System.Reflection;
using System.ComponentModel;
using System.Runtime.InteropServices;
class MyTypeSequential1
{
}
[StructLayoutAttribute(LayoutKind.Sequential)]
class MyTypeSequential2
{
    public static void Main(string []args)
    {
        try
        {
            // Create an instance of myTypeSeq1.
            MyTypeSequential1 myObj1 = new MyTypeSequential1();
            Type myTypeObj1 = myObj1.GetType();
            // Check for and display the SequentialLayout attribute.
            Console.WriteLine("\nThe object myObj1 has IsLayoutSequential: {0}.", myObj1.GetType().IsLayoutSequential);
            // Create an instance of 'myTypeSeq2' class.
            MyTypeSequential2 myObj2 = new MyTypeSequential2();
            Type myTypeObj2 = myObj2.GetType();
            // Check for and display the SequentialLayout attribute.
            Console.WriteLine("\nThe object myObj2 has IsLayoutSequential: {0}.", myObj2.GetType().IsLayoutSequential);
        }
        catch(Exception e)
        {
            Console.WriteLine("\nAn exception occurred: {0}", e.Message);
        }
    }
}
Imports System.Reflection
Imports System.ComponentModel
Imports System.Runtime.InteropServices

Class MyTypeSequential1
End Class
<StructLayoutAttribute(LayoutKind.Sequential)> Class MyTypeSequential2
    Public Shared Sub Main()
        Try
            ' Create an instance of MyTypeSequential1.
            Dim myObj1 As New MyTypeSequential1()
            Dim myTypeObj1 As Type = myObj1.GetType()
            ' Check for and display the SequentialLayout attribute.
            Console.WriteLine(ControlChars.Cr + "The object myObj1 has IsLayoutSequential: {0}.", myObj1.GetType().IsLayoutSequential.ToString())
            ' Create an instance of MyTypeSequential2.
            Dim myObj2 As New MyTypeSequential2()
            Dim myTypeObj2 As Type = myObj2.GetType()
            ' Check for and display the SequentialLayout attribute.
            Console.WriteLine(ControlChars.Cr + "The object myObj2 has IsLayoutSequential: {0}.", myObj2.GetType().IsLayoutSequential.ToString())
        Catch e As Exception
            Console.WriteLine(ControlChars.Cr + "An exception occurred: {0}", e.Message.ToString())
        End Try
    End Sub
End Class

설명

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

동적 형식의 경우 형식을 만들 때 지정할 수 TypeAttributes.SequentialLayout 있습니다. 코드에서 StructLayoutAttribute 열거형 값이 있는 특성을 LayoutKind.Sequential 형식에 적용하여 레이아웃이 순차적임을 지정합니다.

참고

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

자세한 내용은 CLI(공용 언어 인프라) 설명서에 대한 사양의 섹션 9.1.2"파티션 II: 메타데이터 정의 및 의미 체계"를 참조하세요. 이 설명서는 온라인으로 제공됩니다. MSDN의 ECMA C# 및 공용 언어 인프라 표준 및 Ecma International 웹 사이트의 표준 ECMA-335 - CLI(공용 언어 인프라)를 참조하세요.

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

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

적용 대상

추가 정보