CodeBaseReferenceExpression 类

定义

表示对基类的引用。Represents a reference to the base class.

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

示例

此示例演示CodeBaseReferenceExpression如何使用引用基类方法。This example demonstrates using a CodeBaseReferenceExpression to reference a base class method.

// Example method invoke expression uses CodeBaseReferenceExpression to produce
// a base.Dispose method call
CodeMethodInvokeExpression^ methodInvokeExpression = 
   gcnew CodeMethodInvokeExpression(              // Creates a method invoke expression
      gcnew CodeBaseReferenceExpression,          // targetObjectparameter can be a base class reference
      "Dispose",gcnew array<CodeExpression^>{} ); // Method name and method parameter arguments

// A C# code generator produces the following source code for the preceeding example code:
// base.Dispose();
// Example method invoke expression uses CodeBaseReferenceExpression to produce 
// a base.Dispose method call
CodeMethodInvokeExpression methodInvokeExpression =                 
    
    // Creates a method invoke expression
    new CodeMethodInvokeExpression(
    
    // targetObject parameter can be a 
    // base class reference
    new CodeBaseReferenceExpression(),
    
    // Method name and method parameter arguments
    "Dispose", new CodeExpression[] {});            

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

// base.Dispose();

' Example method invoke expression uses CodeBaseReferenceExpression to produce 
' a base.Dispose method call
Dim methodInvokeExpression As New CodeMethodInvokeExpression( New CodeBaseReferenceExpression(), "Dispose", New CodeExpression() {})    

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

' MyBase.Dispose

注解

CodeBaseReferenceExpression表示对当前类的基类的引用。CodeBaseReferenceExpression represents a reference to the base class of the current class. 基类有时也称为父类或超类。The base class is sometimes also known as the parent class or super class. 在重写方法或属性时, 通常使用对基类的引用, 以便调用该方法或属性的基类实现。References to the base class are commonly used when overriding a method or property in order to call the base class's implementation of that method or property. 例如, 将字符串追加到基类的ToString方法末尾的 ToString 方法的重写将调用 base。中的C#ToString ()。For example, an override of a ToString method that appends a string to the end of the base class's ToString method would call base.ToString() in C#.

构造函数

CodeBaseReferenceExpression()

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

属性

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)

适用于