CodePropertySetValueReferenceExpression 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
表示屬性集方法呼叫的值參數,該參數在屬性集方法中。
public ref class CodePropertySetValueReferenceExpression : System::CodeDom::CodeExpression
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class CodePropertySetValueReferenceExpression : System.CodeDom.CodeExpression
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type CodePropertySetValueReferenceExpression = class
inherit CodeExpression
Public Class CodePropertySetValueReferenceExpression
Inherits CodeExpression
- 繼承
- 屬性
範例
此範例示範使用 a CodePropertySetValueReferenceExpression 來表示傳遞給屬性集合值陳述區塊的值參數。
// Declares a type.
CodeTypeDeclaration type1 = new CodeTypeDeclaration("Type1");
// Declares a constructor.
CodeConstructor constructor1 = new CodeConstructor();
constructor1.Attributes = MemberAttributes.Public;
type1.Members.Add( constructor1 );
// Declares an integer field.
CodeMemberField field1 = new CodeMemberField("System.Int32", "integerField");
type1.Members.Add( field1 );
// Declares a property.
CodeMemberProperty property1 = new CodeMemberProperty();
// Declares a property get statement to return the value of the integer field.
property1.GetStatements.Add( new CodeMethodReturnStatement( new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "integerField") ) );
// Declares a property set statement to set the value to the integer field.
// The CodePropertySetValueReferenceExpression represents the value argument passed to the property set statement.
property1.SetStatements.Add( new CodeAssignStatement( new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "integerField"),
new CodePropertySetValueReferenceExpression() ) );
type1.Members.Add( property1 );
// A C# code generator produces the following source code for the preceeding example code:
// public class Type1
// {
//
// private int integerField;
//
// public Type1()
// {
// }
//
// private int integerProperty
// {
// get
// {
// return this.integerField;
// }
// set
// {
// this.integerField = value;
// }
// }
// }
' Declares a type.
Dim type1 As New CodeTypeDeclaration("Type1")
' Declares a constructor.
Dim constructor1 As New CodeConstructor()
constructor1.Attributes = MemberAttributes.Public
type1.Members.Add(constructor1)
' Declares an integer field.
Dim field1 As New CodeMemberField("System.Int32", "integerField")
type1.Members.Add(field1)
' Declares a property.
Dim property1 As New CodeMemberProperty()
' Declares a property get statement to return the value of the integer field.
property1.GetStatements.Add(New CodeMethodReturnStatement(New CodeFieldReferenceExpression(New CodeThisReferenceExpression(), "integerField")))
' Declares a property set statement to set the value to the integer field.
' The CodePropertySetValueReferenceExpression represents the value argument passed to the property set statement.
property1.SetStatements.Add(New CodeAssignStatement(New CodeFieldReferenceExpression(New CodeThisReferenceExpression(), "integerField"), New CodePropertySetValueReferenceExpression()))
type1.Members.Add(property1)
' A Visual Basic code generator produces the following source code for the preceeding example code:
' Public Class Type1
'
' Private integerField As Integer
'
' Public Sub New()
' MyBase.New()
' End Sub
'
' Private Property integerProperty() As Integer
' Get
' Return Me.integerField
' End Get
' Set(ByVal Value As Integer)
' Me.integerField = value
' End Set
' End Property
' End Class
備註
CodePropertySetValueReferenceExpression 表示屬性集合方法呼叫的值參數,該參數包含於屬性集合方法宣告中。
屬性集方法通常會指派或使用該屬性所指派的值。 在屬性集方法中,此值由 CodeDOM CodePropertySetValueReferenceExpression中以 為 的隱含變數表示。
建構函式
| 名稱 | Description |
|---|---|
| CodePropertySetValueReferenceExpression() |
初始化 CodePropertySetValueReferenceExpression 類別的新執行個體。 |
屬性
| 名稱 | Description |
|---|---|
| UserData |
取得目前物件的使用者可定義資料。 (繼承來源 CodeObject) |
方法
| 名稱 | Description |
|---|---|
| Equals(Object) |
判斷指定的物件是否等於目前的物件。 (繼承來源 Object) |
| GetHashCode() |
做為預設哈希函式。 (繼承來源 Object) |
| GetType() |
取得目前實例的 Type。 (繼承來源 Object) |
| MemberwiseClone() |
建立目前 Object的淺層複本。 (繼承來源 Object) |
| ToString() |
傳回表示目前 物件的字串。 (繼承來源 Object) |