CodeTypeReferenceExpression CodeTypeReferenceExpression CodeTypeReferenceExpression CodeTypeReferenceExpression Class

定義

表示資料型別的參考。Represents a reference to a data type.

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

範例

下列範例示範如何使用CodeTypeReferenceExpression來代表類型的參考。The following example demonstrates use of a CodeTypeReferenceExpression to represent a reference to a type.

// 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可以用來參考特定的資料類型。CodeTypeReferenceExpression can be used to reference a particular data type.

Type屬性會指定要參考的資料類型。The Type property specifies the data type to reference.

建構函式

CodeTypeReferenceExpression() CodeTypeReferenceExpression() CodeTypeReferenceExpression() CodeTypeReferenceExpression()

初始化 CodeTypeReferenceExpression 類別的新執行個體。Initializes a new instance of the CodeTypeReferenceExpression class.

CodeTypeReferenceExpression(CodeTypeReference) CodeTypeReferenceExpression(CodeTypeReference) CodeTypeReferenceExpression(CodeTypeReference) CodeTypeReferenceExpression(CodeTypeReference)

使用指定的型別,初始化 CodeTypeReferenceExpression 類別的新執行個體。Initializes a new instance of the CodeTypeReferenceExpression class using the specified type.

CodeTypeReferenceExpression(String) CodeTypeReferenceExpression(String) CodeTypeReferenceExpression(String) CodeTypeReferenceExpression(String)

使用指定的資料型別名稱,初始化 CodeTypeReferenceExpression 類別的新執行個體。Initializes a new instance of the CodeTypeReferenceExpression class using the specified data type name.

CodeTypeReferenceExpression(Type) CodeTypeReferenceExpression(Type) CodeTypeReferenceExpression(Type) CodeTypeReferenceExpression(Type)

使用指定的資料型別,初始化 CodeTypeReferenceExpression 類別的新執行個體。Initializes a new instance of the CodeTypeReferenceExpression class using the specified data type.

屬性

Type Type Type Type

取得或設定要參考的資料型別。Gets or sets the data type to reference.

UserData UserData UserData UserData

取得目前物件的使用者可定義資料。Gets the user-definable data for the current object.

(Inherited from CodeObject)

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)

適用於