CodeTypeOfExpression Klasse

Definition

Stellt einen typeof-Ausdruck dar. Dies ist 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 von veranschaulicht CodeTypeOfExpression , um einen Ausdruck vom Typ "typeof" darzustellen.

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

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

// Generate code and send the output to the console
provider->GenerateCodeFromExpression(typeof1, Console::Out, gcnew 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.
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

Ein CodeTypeOfExpression stellt einen typeof Ausdruck dar, der zur Laufzeit zurückgibt Type .

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

Verwenden Sie CodeTypeReferenceExpression , um Quellcode darzustellen, der auf einen Typ anhand des Namens verweist, z. B. beim Erstellen eines CodeCastExpression , um ein Objekt in einen namensspezifischen Typ zu umwandeln.

Konstruktoren

CodeTypeOfExpression()

Initialisiert eine neue Instanz der CodeTypeOfExpression-Klasse.

CodeTypeOfExpression(CodeTypeReference)

Initialisiert eine neue Instanz der CodeTypeOfExpression-Klasse.

CodeTypeOfExpression(String)

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

CodeTypeOfExpression(Type)

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

Eigenschaften

Type

Ruft den Datentyp ab, auf den mit dem typeof-Ausdruck verwiesen wird, oder legt diesen fest.

UserData

Ruft die benutzerdefinierbaren Daten für das aktuelle Objekt ab.

(Geerbt von CodeObject)

Methoden

Equals(Object)

Bestimmt, ob das angegebene Objekt gleich dem aktuellen Objekt ist.

(Geerbt von Object)
GetHashCode()

Fungiert als Standardhashfunktion.

(Geerbt von Object)
GetType()

Ruft den Type der aktuellen Instanz ab.

(Geerbt von Object)
MemberwiseClone()

Erstellt eine flache Kopie des aktuellen Object.

(Geerbt von Object)
ToString()

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

(Geerbt von Object)

Gilt für:

Weitere Informationen