Type.IsLayoutSequential Type.IsLayoutSequential Type.IsLayoutSequential Type.IsLayoutSequential Property

정의

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

속성 값

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

구현

예제

다음 예제는 클래스의 인스턴스를 만듭니다를 LayoutKind.Sequential 열거 값을 StructLayoutAttribute 클래스 설정 된 경우 확인를 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

설명

이 속성은 편의 위해 제공 됩니다.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.ExplicitLayout, 및 TypeAttributes.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. 코드에 적용 합니다 StructLayoutAttribute 특성과 LayoutKind.Sequential 열거형 값을 해당 레이아웃은 순차를 지정 하는 형식으로 합니다.In code, apply the StructLayoutAttribute attribute with the LayoutKind.Sequential enumeration value to the type, to specify that layout is sequential.

참고

사용할 수 없습니다는 GetCustomAttributes 결정 하는 방법 여부를 StructLayoutAttribute 형식에 적용 된 합니다.You cannot use the GetCustomAttributes method to determine whether the StructLayoutAttribute has been applied to a type.

자세한 내용은 CLI (공용 언어 인프라) 설명서에 대 한 사양 9.1.2 섹션을 참조 하세요. "Partition II: 메타 데이터 정의 및 의미 체계 ".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> (MyGenericType(Of Integer) Visual basic에서),이 속성의 값으로 결정 됩니다 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.

적용 대상

추가 정보