CodeTypeReferenceExpression 類別

定義

表示資料型別的參考。

public ref class CodeTypeReferenceExpression : System::CodeDom::CodeExpression
public class CodeTypeReferenceExpression : System.CodeDom.CodeExpression
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class CodeTypeReferenceExpression : System.CodeDom.CodeExpression
type CodeTypeReferenceExpression = class
    inherit CodeExpression
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type CodeTypeReferenceExpression = class
    inherit CodeExpression
Public Class CodeTypeReferenceExpression
Inherits CodeExpression
繼承
CodeTypeReferenceExpression
屬性

範例

下列範例示範如何使用 CodeTypeReferenceExpression 來表示型別的參考。

// Creates an expression referencing the System.DateTime type.
CodeTypeReferenceExpression^ typeRef1 = gcnew CodeTypeReferenceExpression("System.DateTime");

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

// Generate code and send the output to the console
provider->GenerateCodeFromExpression(typeRef1, Console::Out, gcnew CodeGeneratorOptions());
// The code generator produces the following source code for the preceeding example code:

//    System.DateTime
// Creates an expression referencing the System.DateTime type.
CodeTypeReferenceExpression typeRef1 = new CodeTypeReferenceExpression("System.DateTime");

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

// Generate code and send the output to the console
provider.GenerateCodeFromExpression(typeRef1, Console.Out, new CodeGeneratorOptions());
// The code generator produces the following source code for the preceeding example code:

//    System.DateTime
' Creates an expression referencing the System.DateTime type.
Dim typeRef1 As new CodeTypeReferenceExpression("System.DateTime")

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

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

'    Date

備註

CodeTypeReferenceExpression 可用來參考特定數據類型。

屬性 Type 會指定要參考的數據類型。

建構函式

CodeTypeReferenceExpression()

初始化 CodeTypeReferenceExpression 類別的新執行個體。

CodeTypeReferenceExpression(CodeTypeReference)

使用指定的型別,初始化 CodeTypeReferenceExpression 類別的新執行個體。

CodeTypeReferenceExpression(String)

使用指定的資料型別名稱,初始化 CodeTypeReferenceExpression 類別的新執行個體。

CodeTypeReferenceExpression(Type)

使用指定的資料型別,初始化 CodeTypeReferenceExpression 類別的新執行個體。

屬性

Type

取得或設定要參考的資料型別。

UserData

取得目前物件的使用者可定義資料。

(繼承來源 CodeObject)

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於