CodeTypeOfExpression-Klasse
Stellt einen typeof-Ausdruck dar. Dies ist ein Ausdruck, der einen Type für einen angegebenen Typnamen zurückgibt.
Namespace: System.CodeDom
Assembly: System (in system.dll)
Syntax
'Declaration
<SerializableAttribute> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<ComVisibleAttribute(True)> _
Public Class CodeTypeOfExpression
Inherits CodeExpression
'Usage
Dim instance As CodeTypeOfExpression
[SerializableAttribute]
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)]
[ComVisibleAttribute(true)]
public class CodeTypeOfExpression : CodeExpression
[SerializableAttribute]
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)]
[ComVisibleAttribute(true)]
public ref class CodeTypeOfExpression : public CodeExpression
/** @attribute SerializableAttribute() */
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */
/** @attribute ComVisibleAttribute(true) */
public class CodeTypeOfExpression extends CodeExpression
SerializableAttribute
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)
ComVisibleAttribute(true)
public class CodeTypeOfExpression extends CodeExpression
Hinweise
Ein CodeTypeOfExpression stellt einen typeof-Ausdruck dar, der zur Laufzeit einen Type zurückgibt.
Die Type-Eigenschaft gibt den Datentyp an, für den ein Type-Objekt zurückgegeben werden soll.
Stellen Sie mithilfe von CodeTypeReferenceExpression Quellcode dar, der anhand des Namens auf einen Typ verweist, z. B. beim Erstellen eines CodeCastExpression zum Umwandeln eines Objekts in einen anhand des Namens angegebenen Typ.
Beispiel
Im folgenden Beispiel wird die Verwendung einer CodeTypeOfExpression zum Darstellen eines typeof-Ausdrucks veranschaulicht.
' Creates a reference to the System.DateTime type.
Dim typeRef1 As New CodeTypeReference("System.DateTime")
' Creates a typeof expression for the specified type reference.
Dim typeof1 As New CodeTypeOfExpression(typeRef1)
' A Visual Basic code generator produces the following source code for the preceeding example code:
' GetType(System.DateTime)
// Creates a reference to the System.DateTime type.
CodeTypeReference typeRef1 = new CodeTypeReference("System.DateTime");
// Creates a typeof expression for the specified type reference.
CodeTypeOfExpression typeof1 = new CodeTypeOfExpression(typeRef1);
// A C# code generator produces the following source code for the preceeding example code:
// typeof(System.DateTime);
// Creates a reference to the System.DateTime type.
CodeTypeReference^ typeRef1 = gcnew CodeTypeReference( "System.DateTime" );
// Creates a typeof expression for the specified type reference.
CodeTypeOfExpression^ typeof1 = gcnew CodeTypeOfExpression( typeRef1 );
// A C# code generator produces the following source code for the preceeding example code:
// typeof(System.DateTime);
// Creates a reference to the System.DateTime type.
CodeTypeReference typeRef1 = new CodeTypeReference("System.DateTime");
// Creates a typeof expression for the specified type reference.
CodeTypeOfExpression typeof1 = new CodeTypeOfExpression(typeRef1);
// A VJ# code generator produces the following source code for the
// preceeding example code:
// System.DateTime.class.ToType();
Vererbungshierarchie
System.Object
System.CodeDom.CodeObject
System.CodeDom.CodeExpression
System.CodeDom.CodeTypeOfExpression
Threadsicherheit
Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.
Plattformen
Windows 98, Windows 2000 SP4, Windows Millennium Edition, 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
CodeTypeOfExpression-Member
System.CodeDom-Namespace
CodeTypeReferenceExpression