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。それ以外の場合は falsetrue 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
Imports System.Reflection
Imports System.ComponentModel
Imports System.Runtime.InteropServices
Imports Microsoft.VisualBasic
Class MyTypeSequential1
End Class 'MyTypeSequential1
<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 'Main
End Class 'MyTypeSeq2

注釈

このプロパティは、便利なように提供されます。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.AutoLayoutTypeAttributes.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」セクションを参照してください。"第 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# and Common Language Infrastructure Standards」 (ECMA の C# および共通言語基盤の標準規格) と、ECMA のインターナショナル Web サイトにある「Standard ECMA-335 - Common Language Infrastructure (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.

適用対象

こちらもご覧ください