Type.IsLayoutSequential Property

Definition

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

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

Property Value

Boolean

현재 형식의 true 속성에 Attributes이 포함되어 있으면 SequentialLayout이고, 그렇지 않으면 false입니다.true if the Attributes property of the current type includes SequentialLayout; otherwise, false.

Implements

Examples

다음 예제에서는 StructLayoutAttribute 클래스의 LayoutKind.Sequential 열거형 값이 설정 된 클래스의 인스턴스를 만들고, IsLayoutSequential 속성을 확인 하 고, 결과를 표시 합니다.The following example creates an instance of a class for which the LayoutKind.Sequential enumeration value in the StructLayoutAttribute class has been set, checks for the IsLayoutSequential property, and displays the result.

#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

Remarks

이 속성은 편의 위해 제공 됩니다.This property is provided as a convenience. 또는 TypeAttributes.LayoutMask 열거형 값을 사용 하 여 형식 레이아웃 특성을 선택한 다음 TypeAttributes.SequentialLayout 설정 되어 있는지 여부를 테스트할 수 있습니다.Alternatively, you can use the TypeAttributes.LayoutMask enumeration value to select the type layout attributes, and then test whether TypeAttributes.SequentialLayout is set. TypeAttributes.AutoLayout, TypeAttributes.ExplicitLayoutTypeAttributes.SequentialLayout 열거형 값은 형식의 필드가 메모리에 배치 되는 방식을 지정 합니다.The TypeAttributes.AutoLayout, TypeAttributes.ExplicitLayout, and TypeAttributes.SequentialLayout enumeration values indicate the way the fields of the type are laid out in memory.

동적 형식의 경우 형식을 만들 때 TypeAttributes.SequentialLayout 지정할 수 있습니다.For dynamic types, you can specify TypeAttributes.SequentialLayout when you create the type. 코드에서 LayoutKind.Sequential 열거형 값을 사용 하 여 StructLayoutAttribute 특성을 형식에 적용 하 여 레이아웃이 순차적 임을 지정 합니다.In code, apply the StructLayoutAttribute attribute with the LayoutKind.Sequential enumeration value to the type, to specify that layout is sequential.

Note

GetCustomAttributes 메서드를 사용 하 여 StructLayoutAttribute 형식에 적용 되었는지 여부를 확인할 수 없습니다.You cannot use the GetCustomAttributes method to determine whether the StructLayoutAttribute has been applied to a type.

자세한 내용은 "파티션 II: 메타 데이터 정의 및 의미" 공용 언어 인프라 (CLI) 설명서에 대 한 사양의 9.1.2 섹션을 참조 하세요.For more information, see section 9.1.2 of the specification for the Common Language Infrastructure (CLI) documentation, "Partition II: Metadata Definition and Semantics". 이 설명서는 온라인으로 제공됩니다. MSDN의 ECMA C# 및 공용 언어 인프라 표준 및 Ecma International 웹 사이트의 표준 ECMA-335 - CLI(공용 언어 인프라)를 참조하세요.The documentation is available online; see ECMA C# and Common Language Infrastructure Standards on MSDN and Standard ECMA-335 - Common Language Infrastructure (CLI) on the Ecma International Web site.

현재 Type이 생성 된 제네릭 형식을 나타내는 경우이 속성은 형식이 생성 된 제네릭 형식 정의에 적용 됩니다.If the current Type represents a constructed generic type, this property applies to the generic type definition from which the type was constructed. 예를 들어 현재 Type MyGenericType<int> (Visual Basic의MyGenericType(Of Integer))를 나타내는 경우이 속성의 값은 MyGenericType<T>에 의해 결정 됩니다.For example, if the current Type represents MyGenericType<int> (MyGenericType(Of Integer) in Visual Basic), the value of this property is determined by MyGenericType<T>.

현재 Type 제네릭 형식 또는 제네릭 메서드 정의의 형식 매개 변수를 나타내는 경우이 속성은 항상 false를 반환 합니다.If the current Type represents a type parameter in the definition of a generic type or generic method, this property always returns false.

Applies to

See also