CodePropertyReferenceExpression 类

定义

表示属性值的引用。Represents a reference to the value of a property.

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

示例

下面的示例代码演示CodePropertyReferenceExpression如何使用来引用属性。The following example code demonstrates use of a CodePropertyReferenceExpression to refer to a property.

CodePropertyReferenceExpression^ propertyRef1 = gcnew CodePropertyReferenceExpression( gcnew CodeThisReferenceExpression,"TestProperty" );

// A C# code generator produces the following source code for the preceeding example code:
//    this.TestProperty
CodePropertyReferenceExpression propertyRef1 = 
    new CodePropertyReferenceExpression(new CodeThisReferenceExpression(), "TestProperty");

// A C# code generator produces the following source code for the preceeding example code:

//    this.TestProperty
Dim propertyRef1 As New CodePropertyReferenceExpression(New CodeThisReferenceExpression(), "TestProperty")
' A Visual Basic code generator produces the following source code for the preceeding example code:

'	Me.TestProperty

注解

CodePropertyReferenceExpression可用于表示对属性值的引用。CodePropertyReferenceExpression can be used to represent a reference to the value of a property.

TargetObject属性指定包含要引用的属性的对象。The TargetObject property specifies the object that contains the property to reference. PropertyName属性指定要引用的属性的名称。The PropertyName property specifies the name of the property to reference.

此对象没有属性来指示引用是在getset中使用。This object does not have a property to indicate whether the reference is used in a get or set. 如果在赋值语句的左侧指定了属性引用, 则为; 否则为setIf the property reference occurs on the left, assigned to, side of an assignment statement, then it is a set.

构造函数

CodePropertyReferenceExpression()

初始化 CodePropertyReferenceExpression 类的新实例。Initializes a new instance of the CodePropertyReferenceExpression class.

CodePropertyReferenceExpression(CodeExpression, String)

使用指定的目标对象和属性名称初始化 CodePropertyReferenceExpression 类的新实例。Initializes a new instance of the CodePropertyReferenceExpression class using the specified target object and property name.

属性

PropertyName

获取或设置要引用的属性名。Gets or sets the name of the property to reference.

TargetObject

获取或设置包含要引用属性的对象。Gets or sets the object that contains the property 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)

适用于