CodeTypeReferenceExpression 类

定义

表示对某数据类型的引用。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
继承
CodeTypeReferenceExpression
属性

示例

下面的示例演示如何使用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 类的新实例。Initializes a new instance of the CodeTypeReferenceExpression class.

CodeTypeReferenceExpression(CodeTypeReference)

使用指定的类型初始化 CodeTypeReferenceExpression 类的新实例。Initializes a new instance of the CodeTypeReferenceExpression class using the specified type.

CodeTypeReferenceExpression(String)

使用指定的数据类型名称初始化 CodeTypeReferenceExpression 类的新实例。Initializes a new instance of the CodeTypeReferenceExpression class using the specified data type name.

CodeTypeReferenceExpression(Type)

使用指定的数据类型初始化 CodeTypeReferenceExpression 类的新实例。Initializes a new instance of the CodeTypeReferenceExpression class using the specified data type.

属性

Type

获取或设置要引用的数据类型。Gets or sets the data type to reference.

UserData

获取当前对象的用户可定义数据。Gets the user-definable data for the current object.

(继承自 CodeObject)

方法

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

适用于