Edit

Share via


CodePropertyReferenceExpression Class

Definition

Represents a reference to the value of a property.

C#
public class CodePropertyReferenceExpression : System.CodeDom.CodeExpression
C#
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class CodePropertyReferenceExpression : System.CodeDom.CodeExpression
Inheritance
CodePropertyReferenceExpression
Attributes

Examples

The following example code demonstrates use of a CodePropertyReferenceExpression to refer to a property.

C#
CodePropertyReferenceExpression propertyRef1 =
    new CodePropertyReferenceExpression(new CodeThisReferenceExpression(), "TestProperty");

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

//    this.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

Product Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9