Freigeben über


CodeTypeOfExpression Klasse

Definition

Stellt einen typeof Ausdruck dar, ein Ausdruck, der einen Type für einen angegebenen Typnamen zurückgibt.

public ref class CodeTypeOfExpression : System::CodeDom::CodeExpression
public class CodeTypeOfExpression : System.CodeDom.CodeExpression
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class CodeTypeOfExpression : System.CodeDom.CodeExpression
type CodeTypeOfExpression = class
    inherit CodeExpression
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type CodeTypeOfExpression = class
    inherit CodeExpression
Public Class CodeTypeOfExpression
Inherits CodeExpression
Vererbung
CodeTypeOfExpression
Attribute

Beispiele

Im folgenden Beispiel wird die Verwendung eines CodeTypeOfExpression Typs eines Ausdrucks veranschaulicht.

// 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);

// Create a C# code provider
CodeDomProvider provider = CodeDomProvider.CreateProvider("CSharp");

// Generate code and send the output to the console
provider.GenerateCodeFromExpression(typeof1, Console.Out, new CodeGeneratorOptions());
// The code generator produces the following source code for the preceeding example code:
//    typeof(System.DateTime)
' 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)

' Create a Visual Basic code provider
Dim provider As CodeDomProvider = CodeDomProvider.CreateProvider("VisualBasic")

' Generate code and send the output to the console
provider.GenerateCodeFromExpression(typeof1, Console.Out, new CodeGeneratorOptions())
' The code generator produces the following source code for the preceeding example code:
'    GetType(Date)

Hinweise

A CodeTypeOfExpression represents a typeof expression that returns a Type at runtime.

Die Type Eigenschaft gibt den Datentyp an, für den ein Type Objekt zurückgegeben werden soll.

Wird CodeTypeReferenceExpression verwendet, um Quellcode darzustellen, der auf einen Typ nach Namen verweist, z. B. beim Erstellen eines Objekts zum Umwandeln eines CodeCastExpression Objekts in einen namenspezifischen Typ.

Konstruktoren

Name Beschreibung
CodeTypeOfExpression()

Initialisiert eine neue Instanz der CodeTypeOfExpression-Klasse.

CodeTypeOfExpression(CodeTypeReference)

Initialisiert eine neue Instanz der CodeTypeOfExpression-Klasse.

CodeTypeOfExpression(String)

Initialisiert eine neue Instanz der CodeTypeOfExpression Klasse mithilfe des angegebenen Typs.

CodeTypeOfExpression(Type)

Initialisiert eine neue Instanz der CodeTypeOfExpression Klasse mithilfe des angegebenen Typs.

Eigenschaften

Name Beschreibung
Type

Dient zum Abrufen oder Festlegen des Datentyps, auf den vom typeof Ausdruck verwiesen wird.

UserData

Ruft die vom Benutzer definierbaren Daten für das aktuelle Objekt ab.

(Geerbt von CodeObject)

Methoden

Name Beschreibung
Equals(Object)

Bestimmt, ob das angegebene Objekt dem aktuellen Objekt entspricht.

(Geerbt von Object)
GetHashCode()

Dient als Standardhashfunktion.

(Geerbt von Object)
GetType()

Ruft die Type der aktuellen Instanz ab.

(Geerbt von Object)
MemberwiseClone()

Erstellt eine flache Kopie der aktuellen Object.

(Geerbt von Object)
ToString()

Gibt eine Zeichenfolge zurück, die das aktuelle Objekt darstellt.

(Geerbt von Object)

Gilt für:

Weitere Informationen