This documentation is archived and is not being maintained.

CodeThisReferenceExpression Class

Represents a reference to the current local class instance.

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

System.Object
   System.CodeDom.CodeObject
      System.CodeDom.CodeExpression
         System.CodeDom.CodeThisReferenceExpression

[Visual Basic]
<Serializable>
<ClassInterface(ClassInterfaceType.AutoDispatch)>
<ComVisible(True)>
Public Class CodeThisReferenceExpression
   Inherits CodeExpression
[C#]
[Serializable]
[ClassInterface(ClassInterfaceType.AutoDispatch)]
[ComVisible(true)]
public class CodeThisReferenceExpression : CodeExpression
[C++]
[Serializable]
[ClassInterface(ClassInterfaceType::AutoDispatch)]
[ComVisible(true)]
public __gc class CodeThisReferenceExpression : public
   CodeExpression
[JScript]
public
   Serializable
 ClassInterface(ClassInterfaceType.AutoDispatch)
 ComVisible(true)
class CodeThisReferenceExpression 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

This can represent the class object that is referenced by "this" or "me".

Example

[Visual Basic, C#, C++] The following example code demonstrates use of a CodeThisReferenceExpression to refer to the current object.

[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

CodeThisReferenceExpression Members | System.CodeDom Namespace

Show: