CodeMethodReferenceExpression 类

定义

表示方法的引用。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
继承
CodeMethodReferenceExpression
属性

示例

下面的代码示例使用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可用于表示 form 对象的表达式。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.

与 a CodeMethodInvokeExpression一起使用, 以指示要CodeDelegateCreateExpression调用的方法, 并使用指示用于处理事件的方法。 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 类的新实例。Initializes a new instance of the CodeMethodReferenceExpression class.

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 类的新实例。Initializes a new instance of the CodeMethodReferenceExpression class using the specified target object, method name, and generic type arguments.

属性

MethodName

获取或设置要引用的方法的名称。Gets or sets the name of the method to reference.

TargetObject

获取或设置指示要引用方法的表达式。Gets or sets the expression that indicates the method to reference.

TypeArguments

获取当前泛型方法引用表达式的类型参数。Gets the type arguments for the current generic method reference expression.

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)

适用于