Export (0) Print
Expand All

CodeMethodReferenceExpression Class

Represents a reference to a method.

For a list of all members of this type, see CodeMethodReferenceExpression Members.

System.Object
   System.CodeDom.CodeObject
      System.CodeDom.CodeExpression
         System.CodeDom.CodeMethodReferenceExpression

[Visual Basic]
<Serializable>
<ClassInterface(ClassInterfaceType.AutoDispatch)>
<ComVisible(True)>
Public Class CodeMethodReferenceExpression
   Inherits CodeExpression
[C#]
[Serializable]
[ClassInterface(ClassInterfaceType.AutoDispatch)]
[ComVisible(true)]
public class CodeMethodReferenceExpression : CodeExpression
[C++]
[Serializable]
[ClassInterface(ClassInterfaceType::AutoDispatch)]
[ComVisible(true)]
public __gc class CodeMethodReferenceExpression : public
   CodeExpression
[JScript]
public
   Serializable
 ClassInterface(ClassInterfaceType.AutoDispatch)
 ComVisible(true)
class CodeMethodReferenceExpression extends CodeExpression

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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.

Example

[Visual Basic, C#, C++] The following example code uses a CodeMethodReferenceExpression to refer to a method:

[Visual Basic] 
' 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


[C#] 
// 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();


[C++] 
// Invokes the TestMethod method of the current type object.
CodeMethodReferenceExpression* methodRef1 = new CodeMethodReferenceExpression( new CodeThisReferenceExpression(), S"TestMethod" );

CodeParameterDeclarationExpression* temp1 [];
CodeMethodInvokeExpression* invoke1 = new CodeMethodInvokeExpression( methodRef1, temp1 );

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

//        this.TestMethod();

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.CodeDom

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: System (in System.dll)

See Also

CodeMethodReferenceExpression Members | System.CodeDom Namespace

Show:
© 2014 Microsoft