CodeMethodInvokeExpression 类

定义

表示调用方法的表达式。Represents an expression that invokes a method.

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

示例

此示例演示CodeMethodInvokeExpression如何使用来调用方法。This example demonstrates using a CodeMethodInvokeExpression to invoke a method.

array<CodeExpression^>^temp0 = {gcnew CodePrimitiveExpression( true )};

// parameters array contains the parameters for the method.
CodeMethodInvokeExpression^ methodInvoke = gcnew CodeMethodInvokeExpression( gcnew CodeThisReferenceExpression,"Dispose",temp0 );

// A C# code generator produces the following source code for the preceeding example code:
// this.Dispose(true);
CodeMethodInvokeExpression methodInvoke = new CodeMethodInvokeExpression(
    // targetObject that contains the method to invoke.
    new CodeThisReferenceExpression(),
    // methodName indicates the method to invoke.
    "Dispose",
    // parameters array contains the parameters for the method.
    new CodeExpression[] { new CodePrimitiveExpression(true) } );

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

// this.Dispose(true);
' This CodeMethodInvokeExpression calls Me.Dispose(true)

    ' The targetObject parameter indicates the object containing the method to invoke.
    ' The methodName parameter indicates the method to invoke.
    ' The parameters array contains the parameters for the method invoke.

    Dim methodInvoke As New CodeMethodInvokeExpression( _
       New CodeThisReferenceExpression(), _
       "Dispose", _
       New CodeExpression() {New CodePrimitiveExpression(True)})

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

    ' Me.Dispose(true)

注解

CodeMethodInvokeExpression可用于表示调用方法的表达式。CodeMethodInvokeExpression can be used to represent an expression that invokes a method.

Method属性指定要调用的方法。The Method property specifies the method to invoke. Parameters属性指示要传递给方法的参数。The Parameters property indicates the parameters to pass to the method. CodeDirectionExpression使用指定参数的字段方向。Use a CodeDirectionExpression to specify the field direction of a parameter.

构造函数

CodeMethodInvokeExpression()

初始化 CodeMethodInvokeExpression 类的新实例。Initializes a new instance of the CodeMethodInvokeExpression class.

CodeMethodInvokeExpression(CodeExpression, String, CodeExpression[])

使用指定的目标对象、方法名称和参数初始化 CodeMethodInvokeExpression 类的新实例。Initializes a new instance of the CodeMethodInvokeExpression class using the specified target object, method name, and parameters.

CodeMethodInvokeExpression(CodeMethodReferenceExpression, CodeExpression[])

使用指定的方法和参数初始化 CodeMethodInvokeExpression 类的新实例。Initializes a new instance of the CodeMethodInvokeExpression class using the specified method and parameters.

属性

Method

获取或设置要调用的方法。Gets or sets the method to invoke.

Parameters

获取要调用该方法的参数。Gets the parameters to invoke the method with.

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)

适用于

另请参阅