ערוך

שתף באמצעות


CodeMethodReferenceExpression Class

Definition

Represents a reference to a method.

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
Inheritance
CodeMethodReferenceExpression
Attributes

Examples

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

Remarks

A CodeMethodReferenceExpression can be used to represent an expression of the form Object.Method.

The TargetObject property indicates the object that contains the method. The MethodName property indicates the name of the method.

A CodeMethodReferenceExpression is used with a CodeMethodInvokeExpression to indicate the method to invoke, and with a CodeDelegateCreateExpression to indicate the method to handle the event.

Constructors

CodeMethodReferenceExpression()

Initializes a new instance of the CodeMethodReferenceExpression class.

CodeMethodReferenceExpression(CodeExpression, String)

Initializes a new instance of the CodeMethodReferenceExpression class using the specified target object and method name.

CodeMethodReferenceExpression(CodeExpression, String, CodeTypeReference[])

Initializes a new instance of the CodeMethodReferenceExpression class using the specified target object, method name, and generic type arguments.

Properties

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.

(Inherited from CodeObject)

Methods

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to