Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Ruft einen Wert ab, der angibt, ob für Type das Klassenlayoutattribut ExplicitLayout ausgewählt ist.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
Public ReadOnly Property IsExplicitLayout As Boolean
'Usage
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 ()
public final function get IsExplicitLayout () : boolean
Eigenschaftenwert
true, wenn für Type das Klassenlayoutattribut ExplicitLayout ausgewählt ist, andernfalls false.
Hinweise
Die Klassenlayoutattribute werden mit LayoutMask ausgewählt. Die Klassenlayoutattribute (AutoLayout, SequentialLayout und ExplicitLayout) definieren das Layout der Felder der Klasseninstanz im Speicher.
Bei Klassen, die mit dem ExplicitLayout-Attribut markiert sind, beachtet das Ladeprogramm die Feldreihenfolge nicht, sondern verwendet die explizit angegebenen Layoutregeln hinsichtlich Feldoffsets, Klassengesamtgröße und Ausrichtung oder all dieser Merkmale.
Verwenden Sie das ExplicitLayout-Attribut zur Angabe der Offsets für den Beginn jedes Felds, der Gesamtgröße und optional der Packungsgröße der Klassenobjekte. Die Packungsgröße ist der freie Speicherplatz zwischen Feldern und muss 1,2,4,8 oder 16 Bytes betragen.
Wenn der aktuelle Type einen konstruierten generischen Typ darstellt, gilt diese Eigenschaft für die generische Typdefinition, aus der der Typ konstruiert wurde. Wenn z. B. der aktuelle TypeMyGenericType<int> darstellt (MyGenericType(Of Integer) in Visual Basic), wird der Wert dieser Eigenschaft durch MyGenericType<T> bestimmt.
Wenn der aktuelle Type einen Typparameter in der Definition eines generischen Typs oder einer generischen Methoden darstellt, gibt diese Eigenschaft immer false zurück.
Beispiel
Im folgenden Beispiel wird eine Instanz des angegebenen Typs erstellt, und die IsExplicitLayout-Eigenschaft der MyDemoAttribute-Klasse wird angezeigt.
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
Plattformen
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
Type-Klasse
Type-Member
System-Namespace
TypeAttributes
Type.IsAutoLayout-Eigenschaft
IsLayoutSequential