super keyword(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#中究竟需要等效的超级关键字
最初尝试使用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);
}
}
任何人都可以帮助我。
答案 0 :(得分:58)
与您的代码相当的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);
}
}