java - C#中 super 关键字的等价物

标签 java c# super base

super关键字(java)等价的c#关键字是什么。

我的java代码:

public class PrintImageLocations extends PDFStreamEngine
{
    public PrintImageLocations() throws IOException
    {
        super( ResourceLoader.loadProperties( "org/apache/pdfbox/resources/PDFTextStripper.properties", true ) );
    } 

     protected void processOperator( PDFOperator operator, List arguments ) throws IOException
    {
     super.processOperator( operator, arguments );
    }

现在我需要什么相当于 C# 中的 super 关键字 最初尝试使用 base 是否以正确的方式使用关键字 base

class Imagedata : PDFStreamEngine
{
   public Imagedata() : base()
   {                                          
         ResourceLoader.loadProperties("org/apache/pdfbox/resources/PDFTextStripper.properties", true);
   }

   protected override void processOperator(PDFOperator operations, List arguments)
   {
      base.processOperator(operations, arguments);
   }
}

谁能帮帮我。

最佳答案

C#相当于你的代码

  class Imagedata : PDFStreamEngine
  {
     // C# uses "base" keyword whenever Java uses "super" 
     // so instead of super(...) in Java we should call its C# equivalent (base):
     public Imagedata()
       : base(ResourceLoader.loadProperties("org/apache/pdfbox/resources/PDFTextStripper.properties", true)) 
     { }

     // Java methods are virtual by default, when C# methods aren't.
     // So we should be sure that processOperator method in base class 
     // (that is PDFStreamEngine)
     // declared as "virtual"
     protected override void processOperator(PDFOperator operations, List arguments)
     {
        base.processOperator(operations, arguments);
     }
  }

关于java - C#中 super 关键字的等价物,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17486853/

相关文章:

java - 将文本框的文本与字符串进行比较会导致异常

java - Spring容器实例化、配置和组装对象

javascript - 您可以从函数绑定(bind)中读取连接字符串吗?

java - 在 Java 类型参数中,<? extends E> 仅表示严格的子类型?还是 E 也足够?

java - 如何在运行时更改线程的 Runnable 目标

java - Objective C 和 Java 之间的网络

C# 数组子集获取

c# - 对已定义命名空间中的所有类使用 Ninject.InSingletonScope()

Python: 'super' 对象没有属性 'attribute_name'

java - Java 泛型中 "super"通配符的详细信息