CodeMethodReferenceExpression 类

定义

表示方法的引用。

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

示例

下面的代码示例使用 CodeMethodReferenceExpression 来引用 方法:

// 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可用于表示 Object.Method 形式的表达式。

属性 TargetObject 指示包含 方法的对象。 属性 MethodName 指示方法的名称。

CodeMethodReferenceExpression与 一起使用CodeMethodInvokeExpression来指示要调用的方法,使用 CodeDelegateCreateExpression 指示处理事件的方法。

构造函数

CodeMethodReferenceExpression()

初始化 CodeMethodReferenceExpression 类的新实例。

CodeMethodReferenceExpression(CodeExpression, String)

使用指定的目标对象和方法名初始化 CodeMethodReferenceExpression 类的新实例。

CodeMethodReferenceExpression(CodeExpression, String, CodeTypeReference[])

使用指定的目标对象、方法名称和泛型类型参数初始化 CodeMethodReferenceExpression 类的新实例。

属性

MethodName

获取或设置要引用的方法的名称。

TargetObject

获取或设置指示要引用方法的表达式。

TypeArguments

获取当前泛型方法引用表达式的类型参数。

UserData

获取当前对象的用户可定义数据。

(继承自 CodeObject)

方法

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ToString()

返回表示当前对象的字符串。

(继承自 Object)

适用于