CodeTypeOfExpression Osztály

Definíció

Egy typeof kifejezés, egy kifejezés, amely egy Type megadott típusnevet ad vissza.

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
Öröklődés
CodeTypeOfExpression
Attribútumok

Példák

Az alábbi példa egy kifejezéstípust ábrázoló használatát CodeTypeOfExpression mutatja be.

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

Megjegyzések

CodeTypeOfExpression Az a typeof kifejezés, amely futásidőben ad vissza egy Type kifejezést.

A Type tulajdonság azt az adattípust adja meg, amely egy objektumot ad vissza Type .

Olyan CodeTypeReferenceExpression forráskódot jelöl, amely név szerint hivatkozik egy típusra, például amikor létrehoz egy CodeCastExpression objektumot egy névvel megadott típusra.

Konstruktorok

Name Description
CodeTypeOfExpression()

Inicializálja a CodeTypeOfExpression osztály új példányát.

CodeTypeOfExpression(CodeTypeReference)

Inicializálja a CodeTypeOfExpression osztály új példányát.

CodeTypeOfExpression(String)

Inicializálja az CodeTypeOfExpression osztály új példányát a megadott típussal.

CodeTypeOfExpression(Type)

Inicializálja az CodeTypeOfExpression osztály új példányát a megadott típussal.

Tulajdonságok

Name Description
Type

Lekéri vagy beállítja a kifejezés által hivatkozott adattípust typeof .

UserData

Lekéri az aktuális objektum felhasználó által definiálható adatait.

(Öröklődés forrása CodeObject)

Metódusok

Name Description
Equals(Object)

Meghatározza, hogy a megadott objektum egyenlő-e az aktuális objektummal.

(Öröklődés forrása Object)
GetHashCode()

Ez az alapértelmezett kivonatoló függvény.

(Öröklődés forrása Object)
GetType()

Lekéri az Type aktuális példányt.

(Öröklődés forrása Object)
MemberwiseClone()

Az aktuális Objectpéldány sekély másolatát hozza létre.

(Öröklődés forrása Object)
ToString()

Az aktuális objektumot jelképező sztringet ad vissza.

(Öröklődés forrása Object)

A következőre érvényes:

Lásd még