編輯

共用方式為


CodePropertyReferenceExpression Class

Definition

Represents a reference to the value of a property.

public ref class CodePropertyReferenceExpression : System::CodeDom::CodeExpression
public class CodePropertyReferenceExpression : System.CodeDom.CodeExpression
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class CodePropertyReferenceExpression : System.CodeDom.CodeExpression
type CodePropertyReferenceExpression = class
    inherit CodeExpression
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type CodePropertyReferenceExpression = class
    inherit CodeExpression
Public Class CodePropertyReferenceExpression
Inherits CodeExpression
Inheritance
CodePropertyReferenceExpression
Attributes

Examples

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

Remarks

CodePropertyReferenceExpression can be used to represent a reference to the value of a property.

The TargetObject property specifies the object that contains the property to reference. The PropertyName property specifies the name of the property to reference.

This object does not have a property to indicate whether the reference is used in a get or set. If the property reference occurs on the left, assigned to, side of an assignment statement, then it is a set.

Constructors

CodePropertyReferenceExpression()

Initializes a new instance of the CodePropertyReferenceExpression class.

CodePropertyReferenceExpression(CodeExpression, String)

Initializes a new instance of the CodePropertyReferenceExpression class using the specified target object and property name.

Properties

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.

(Inherited from CodeObject)

Methods

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to