Type.IsAutoLayout Property
Gets a value indicating whether the class layout attribute AutoLayout is selected for the Type.
[Visual Basic] Public ReadOnly Property IsAutoLayout As Boolean [C#] public bool IsAutoLayout {get;} [C++] public: __property bool get_IsAutoLayout(); [JScript] public function get IsAutoLayout() : Boolean;
Property Value
true if the class layout attribute AutoLayout is selected for the Type; otherwise, false.
Remarks
The LayoutMask is used to select the class layout attributes. The class layout attributes (AutoLayout, SequentialLayout and ExplicitLayout) define how the fields of the class instance are laid out in memory.
Use the AutoLayout attribute to let the runtime engine decide the best way to layout the objects of the class. Classes marked with the AutoLayout attribute indicate that the loader will choose the appropriate way to lay out the class; any layout information that may have been specified is ignored.
Example
[Visual Basic, C#, C++] The following example creates an instance of the type and displays the IsAutoLayout property.
[Visual Basic] 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] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard
See Also
Type Class | Type Members | System Namespace | TypeAttributes | IsLayoutSequential | IsExplicitLayout | Metadata Overview