Freigeben über


CodeMethodReferenceExpression-Klasse

Stellt einen Verweis auf eine Methode dar.

Namespace: System.CodeDom
Assembly: System (in system.dll)

Syntax

'Declaration
<SerializableAttribute> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<ComVisibleAttribute(True)> _
Public Class CodeMethodReferenceExpression
    Inherits CodeExpression
'Usage
Dim instance As CodeMethodReferenceExpression
[SerializableAttribute] 
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] 
[ComVisibleAttribute(true)] 
public class CodeMethodReferenceExpression : CodeExpression
[SerializableAttribute] 
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] 
[ComVisibleAttribute(true)] 
public ref class CodeMethodReferenceExpression : public CodeExpression
/** @attribute SerializableAttribute() */ 
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ 
/** @attribute ComVisibleAttribute(true) */ 
public class CodeMethodReferenceExpression extends CodeExpression
SerializableAttribute 
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) 
ComVisibleAttribute(true) 
public class CodeMethodReferenceExpression extends CodeExpression

Hinweise

Mit einer CodeMethodReferenceExpression kann ein Ausdruck der Form Objekt.Methode dargestellt werden.

Eine TargetObject-Eigenschaft gibt das Objekt an, das die Methode enthält. Die MethodName-Eigenschaft gibt den Namen der Methode an.

Eine CodeMethodReferenceExpression wird mit einer CodeMethodInvokeExpression verwendet, um die aufzurufende Methode anzugeben, und mit einer CodeDelegateCreateExpression, um die Methode für die Ereignisbehandlung anzugeben.

Beispiel

Im folgenden Codebeispiel wird mit einer CodeMethodReferenceExpression auf eine Methode verwiesen.

' 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
// 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.
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 VJ# code generator produces the following source code for the 
// preceeding example code:
// this.TestMethod();

Vererbungshierarchie

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

Threadsicherheit

Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Plattformen

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

CodeMethodReferenceExpression-Member
System.CodeDom-Namespace