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/