Bagikan melalui


CodeTypeOfExpression Kelas

Definisi

typeof Mewakili ekspresi, ekspresi yang mengembalikan Type untuk nama jenis tertentu.

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
Warisan
CodeTypeOfExpression
Atribut

Contoh

Contoh berikut menunjukkan penggunaan untuk CodeTypeOfExpression mewakili ekspresi typeof.

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

Keterangan

mewakili CodeTypeOfExpressiontypeof ekspresi yang mengembalikan Type pada runtime.

Properti Type menentukan jenis data untuk Type mengembalikan objek.

Gunakan CodeTypeReferenceExpression untuk mewakili kode sumber yang mengacu pada jenis menurut nama, seperti saat membuat untuk mentransmisikan CodeCastExpression objek ke jenis yang ditentukan nama.

Konstruktor

Nama Deskripsi
CodeTypeOfExpression()

Menginisialisasi instans baru dari kelas CodeTypeOfExpression.

CodeTypeOfExpression(CodeTypeReference)

Menginisialisasi instans baru dari kelas CodeTypeOfExpression.

CodeTypeOfExpression(String)

Menginisialisasi instans CodeTypeOfExpression baru kelas menggunakan jenis yang ditentukan.

CodeTypeOfExpression(Type)

Menginisialisasi instans CodeTypeOfExpression baru kelas menggunakan jenis yang ditentukan.

Properti

Nama Deskripsi
Type

Mendapatkan atau mengatur jenis data yang direferensikan oleh typeof ekspresi.

UserData

Mendapatkan data yang dapat ditetapkan pengguna untuk objek saat ini.

(Diperoleh dari CodeObject)

Metode

Nama Deskripsi
Equals(Object)

Menentukan apakah objek yang ditentukan sama dengan objek saat ini.

(Diperoleh dari Object)
GetHashCode()

Berfungsi sebagai fungsi hash default.

(Diperoleh dari Object)
GetType()

Mendapatkan Type instans saat ini.

(Diperoleh dari Object)
MemberwiseClone()

Membuat salinan dangkal dari Objectsaat ini.

(Diperoleh dari Object)
ToString()

Mengembalikan string yang mewakili objek saat ini.

(Diperoleh dari Object)

Berlaku untuk

Lihat juga