Type.IsExplicitLayoutとは? わかりやすく解説

Type.IsExplicitLayout プロパティ

Type に、クラスのレイアウト属性として ExplicitLayout が選択されているかどうかを示す値を取得します。

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Dim instance As Type
Dim value As Boolean

value = instance.IsExplicitLayout
public bool IsExplicitLayout { get;
 }
public:
virtual property bool IsExplicitLayout {
    bool get () sealed;
}
/** @property */
public final boolean get_IsExplicitLayout ()

プロパティ値
Type に、クラスのレイアウト属性として ExplicitLayout が選択されている場合は true。それ以外の場合は false。

解説解説

LayoutMask は、クラスのレイアウト属性を選択するために使用します。クラス レイアウト属性 (AutoLayout、SequentialLayout、および ExplicitLayout) は、クラス インスタンスのフィールドのメモリ上でのレイアウトを定義します。

ExplicitLayout 属性でクラスをマークすると、ローダーはフィールドの順序を無視し、フィールド オフセット、クラス全体のサイズと配置、またはそれらすべて、などの形で指定されている明示的なレイアウト規則を使用します。

各フィールドの開始位置のオフセット、クラスのオブジェクト全体のサイズ、またはオプションとして、クラスのオブジェクトのパッキング サイズを指定するには、ExplicitLayout 属性を使用します。パッキング サイズはフィールド間の空きメモリ空間であり、1、2、4、8、または 16 バイトである必要があります。

現在の Type が構築ジェネリック型を表している場合、このプロパティは型が構築される元になったジェネリック型定義に適用されます。たとえば、現在の Type が MyGenericType<int> (Visual Basic では MyGenericType(Of Integer)) を表す場合、このプロパティの値は MyGenericType<T> によって決まります。

現在の Type がジェネリック型またはジェネリック メソッドの定義の型パラメータを表している場合、このプロパティは常に false を返します。

使用例使用例

指定した型のインスタンスを作成し、 MyDemoAttribute クラスの IsExplicitLayout プロパティを表示する例を次に示します。

Imports System
Imports System.Reflection
Imports System.ComponentModel
Imports System.Runtime.InteropServices
Imports Microsoft.VisualBasic

'The class to be tested for the ExplicitLayout property.
<StructLayoutAttribute(LayoutKind.Explicit)> _
Public Class Demo
End Class

Public Class MyTypeClass
    Public Shared Sub Main()
        'Create an instance of the type using the GetType method.
        Dim myType As Type = GetType(Demo)
        ' Get and display the IsExplicitLayout property.
        Console.WriteLine(vbCrLf & "The IsExplicitLayout property
 of the Demo type is {0}.", _
            myType.IsExplicitLayout)
    End Sub
End Class
using System;
using System.Reflection;
using System.ComponentModel;
using System.Runtime.InteropServices;
//The class to be tested for the ExplicitLayout property.
[StructLayoutAttribute(LayoutKind.Explicit)]
public class Demo
{
}
public class MyTypeClass
{
    public static void Main(string[]
 args)
    {
        // Create an instance of the type using the GetType method.
        Type  myType = typeof(Demo);
        // Get and display the IsExplicitLayout property.
        Console.WriteLine("\nThe IsExplicitLayout property of the Demo type
 is {0}.", 
            myType.IsExplicitLayout); 
    }
}
#using <System.dll>

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

//The class to be tested for the ExplicitLayout property.

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

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

}

int main()
{
   MyIsExplicitLayoutMethod( "MyDemoAttribute" );
}

import System.*;
import System.Reflection.*;
import System.ComponentModel.*;
import System.Runtime.InteropServices.*;

//The class to be tested for the ExplicitLayout property.
/** @attribute StructLayoutAttribute(LayoutKind.Explicit)
 */
public class MyDemoAttribute
{
} //MyDemoAttribute

public class MyTypeClass
{
    public static void main(String[]
 args)
    {
        MyIsExplicitLayoutMethod("MyDemoAttribute");
    } //main

    public static void MyIsExplicitLayoutMethod(String
 typeName)
    {
        try {
            // Create an instance of the type using the GetType method.
            Type myType = Type.GetType(typeName);
            // Get and display the IsExplicitLayout property.
            Console.WriteLine("\nThe IsExplicitLayout property of the "
 
                + "MyDemoAttribute instance is {0}.", System.Convert.
                ToString(myType.get_IsExplicitLayout()));
        }
        catch (System.Exception e) {
            Console.WriteLine("\nAn exception occurred: {0}.", e.get_Message());
        }
    } //MyIsExplicitLayoutMethod
} //MyTypeClass
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

_Type.IsExplicitLayout プロパティ

メモ : このプロパティは、.NET Framework version 2.0 で新しく追加されたものです。

COM オブジェクトに、Type.IsExplicitLayout プロパティへのバージョンに依存しないアクセスが用意されています。

このプロパティは、CLS に準拠していません。  

名前空間: System.Runtime.InteropServices
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Dim instance As _Type
Dim value As Boolean

value = instance.IsExplicitLayout
bool IsExplicitLayout { get; }
property bool IsExplicitLayout {
    bool get ();
}
/** @property */
boolean get_IsExplicitLayout ()
function get IsExplicitLayout () : boolean

プロパティ値
Type に、クラスのレイアウト属性として ExplicitLayout が選択されている場合は true。それ以外の場合は false。

解説解説

このプロパティは、アンマネージ コードからマネージ クラスにアクセスするためのプロパティであるため、マネージ コードからは呼び出さないでください。

Type.IsExplicitLayout プロパティは、Type に、クラスのレイアウト属性として ExplicitLayout が選択されているかどうかを示す値を取得します。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「Type.IsExplicitLayout」の関連用語

Type.IsExplicitLayoutのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Type.IsExplicitLayoutのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS