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)

适用于