CodeMethodReferenceExpression CodeMethodReferenceExpression CodeMethodReferenceExpression CodeMethodReferenceExpression Class

定義

表示方法的參考。Represents a reference to a method.

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

範例

下列程式碼範例會使用CodeMethodReferenceExpression來參考方法:The following code example uses a CodeMethodReferenceExpression to refer to a method:

// Invokes the TestMethod method of the current type object.
CodeMethodReferenceExpression^ methodRef1 = gcnew CodeMethodReferenceExpression( gcnew CodeThisReferenceExpression,"TestMethod" );
array<CodeParameterDeclarationExpression^>^temp1;
CodeMethodInvokeExpression^ invoke1 = gcnew CodeMethodInvokeExpression( methodRef1,temp1 );

// A C# code generator produces the following source code for the preceeding example code:
//        this.TestMethod();
// Invokes the TestMethod method of the current type object.
CodeMethodReferenceExpression methodRef1 = new CodeMethodReferenceExpression( new CodeThisReferenceExpression(), "TestMethod" );
CodeMethodInvokeExpression invoke1 = new CodeMethodInvokeExpression( methodRef1, new CodeParameterDeclarationExpression[] {} );                                    

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

//        this.TestMethod();

' Invokes the TestMethod method of the current type object.
Dim methodRef1 As New CodeMethodReferenceExpression(New CodeThisReferenceExpression(), "TestMethod")
Dim invoke1 As New CodeMethodInvokeExpression(methodRef1, New CodeParameterDeclarationExpression() {})

' A Visual Basic code generator produces the following source code for the preceeding example code:

'       Me.TestMethod

備註

CodeMethodReferenceExpression可以用來代表表單物件. 方法的運算式。A CodeMethodReferenceExpression can be used to represent an expression of the form Object.Method.

TargetObject屬性會指出包含方法的物件。The TargetObject property indicates the object that contains the method. MethodName屬性會指出方法的名稱。The MethodName property indicates the name of the method.

會與搭配使用CodeDelegateCreateExpression ,以表示要叫用的方法,以及使用來表示處理事件的方法。CodeMethodInvokeExpression CodeMethodReferenceExpressionA CodeMethodReferenceExpression is used with a CodeMethodInvokeExpression to indicate the method to invoke, and with a CodeDelegateCreateExpression to indicate the method to handle the event.

建構函式

CodeMethodReferenceExpression() CodeMethodReferenceExpression() CodeMethodReferenceExpression() CodeMethodReferenceExpression()

初始化 CodeMethodReferenceExpression 類別的新執行個體。Initializes a new instance of the CodeMethodReferenceExpression class.

CodeMethodReferenceExpression(CodeExpression, String) CodeMethodReferenceExpression(CodeExpression, String) CodeMethodReferenceExpression(CodeExpression, String) CodeMethodReferenceExpression(CodeExpression, String)

使用指定的目標物件和方法名稱,來初始化 CodeMethodReferenceExpression 類別的新執行個體。Initializes a new instance of the CodeMethodReferenceExpression class using the specified target object and method name.

CodeMethodReferenceExpression(CodeExpression, String, CodeTypeReference[]) CodeMethodReferenceExpression(CodeExpression, String, CodeTypeReference[]) CodeMethodReferenceExpression(CodeExpression, String, CodeTypeReference[]) CodeMethodReferenceExpression(CodeExpression, String, CodeTypeReference[])

使用指定的目標物件、方法名稱和泛型型別參數初始化 CodeMethodReferenceExpression 類別的新執行個體。Initializes a new instance of the CodeMethodReferenceExpression class using the specified target object, method name, and generic type arguments.

屬性

MethodName MethodName MethodName MethodName

取得或設定要參考的方法名稱。Gets or sets the name of the method to reference.

TargetObject TargetObject TargetObject TargetObject

取得或設定運算式,表示要參考的方法。Gets or sets the expression that indicates the method to reference.

TypeArguments TypeArguments TypeArguments TypeArguments

取得目前泛型方法參考運算式的型別引數。Gets the type arguments for the current generic method reference expression.

UserData UserData UserData UserData

取得目前物件的使用者可定義資料。Gets the user-definable data for the current object.

(Inherited from CodeObject)

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)

適用於