Type に、クラスのレイアウト属性として AutoLayout が選択されているかどうかを示す値を取得します。
Public ReadOnly Property IsAutoLayout As Boolean
[C#]
public bool IsAutoLayout {get;}
[C++]
public: __property bool get_IsAutoLayout();
[JScript]
public function get IsAutoLayout() : Boolean;
プロパティ値
Type に、クラスのレイアウト属性として AutoLayout が選択されている場合は true 。それ以外の場合は false 。
解説
LayoutMask は、クラスのレイアウト属性を選択するために使用します。クラス レイアウト属性 (AutoLayout 、 SequentialLayout 、および ExplicitLayout) は、クラス インスタンスのフィールドのメモリ上でのレイアウトを定義します。
AutoLayout 属性を使用すると、クラスのオブジェクトに最適なレイアウト方法をランタイム エンジンで決定できるようになります。 AutoLayout 属性でクラスをマークすると、そのクラスにとって適切なレイアウトがローダーによって選択され、指定されているその他のレイアウト情報は無視されます。
使用例
[Visual Basic, C#, C++] 型のインスタンスを作成し、 IsAutoLayout プロパティを表示する例を次に示します。
Imports System
Imports System.Reflection
Imports System.ComponentModel
Imports System.Runtime.InteropServices
Imports Microsoft.VisualBasic
' The MyDemoAttribute class is selected as AutoLayout.
<StructLayoutAttribute(LayoutKind.Auto)> Public Class MyDemoAttribute
End Class 'MyDemoAttribute
Public Class MyTypeClass
Public Shared Sub Main()
MyAutoLayoutMethod("MyDemoAttribute")
End Sub 'Main
Public Shared Sub MyAutoLayoutMethod(ByVal typeName As String)
Try
' Create an instance of the Type class using the GetType method.
Dim myType As Type = Type.GetType(typeName)
' Get and display the IsAutoLayout property of the
' MyDemoAttribute instance.
Console.WriteLine(ControlChars.Cr + "The AutoLayout property for the MyDemoAttribute is {0}.", myType.IsAutoLayout.ToString())
Catch e As Exception
Console.WriteLine(ControlChars.Cr + "An exception occurred: {0}.", e.Message.ToString())
End Try
End Sub 'MyAutoLayoutMethod
End Class 'MyTypeClass
[C#]
using System;
using System.Reflection;
using System.ComponentModel;
using System.Runtime.InteropServices;
// The MyDemoAttribute class is selected as AutoLayout.
[StructLayoutAttribute(LayoutKind.Auto)]
public class MyDemoAttribute
{
}
public class MyTypeClass
{
public static void Main(string[] args)
{
MyAutoLayoutMethod("MyDemoAttribute");
}
public static void MyAutoLayoutMethod(string typeName)
{
try
{
// Create an instance of the Type class using the GetType method.
Type myType=Type.GetType(typeName);
// Get and display the IsAutoLayout property of the
// MyDemoAttribute instance.
Console.WriteLine("\nThe AutoLayout property for the MyDemoAttribute is {0}.",myType.IsAutoLayout);
}
catch(Exception e)
{
Console.WriteLine("\nAn exception occurred: {0}." ,e.Message);
}
}
}
[C++]
#using <mscorlib.dll>
#using <System.dll>
using namespace System;
using namespace System::Reflection;
using namespace System::ComponentModel;
using namespace System::Runtime::InteropServices;
// The MyDemoAttribute class is selected as AutoLayout.
[StructLayoutAttribute(LayoutKind::Auto)]
public __gc class MyDemoAttribute {
};
void MyAutoLayoutMethod(String* typeName) {
try {
// Create an instance of the Type class using the GetType method.
Type* myType=Type::GetType(typeName);
// Get and display the IsAutoLayout property of the
// MyDemoAttribute instance.
Console::WriteLine(S"\nThe AutoLayout property for the MyDemoAttribute is {0}.",__box( myType->IsAutoLayout));
} catch (Exception* e) {
Console::WriteLine(S"\nAn exception occurred: {0}." , e->Message);
}
}
int main() {
MyAutoLayoutMethod(S"MyDemoAttribute");
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET, Common Language Infrastructure (CLI) Standard
参照
Type クラス | Type メンバ | System 名前空間 | TypeAttributes | IsLayoutSequential | IsExplicitLayout | メタデータの概要