将Java构造函数从抽象类和super关键字转换为C#时出错?

将Java构造函数从抽象类和super关键字转换为C#时出错?,java,c#,constructor,Java,C#,Constructor,我有两个Java类,我正试图将它们转换为C。一个是名为RemoteButton的抽象类,另一个派生自名为TVRemoteMute的抽象类。我能够转换抽象RemoteButton类中的大多数成员。一个成员是在TVRemoteMute中实现的抽象ButtonnePressed(),另一个是在基类中实现的虚拟成员ButtonFilePressed()。我的问题是TVRemoteMute类的构造函数。它突出显示了两个词:构造函数名和方法内部的super。构造函数名称错误如下:“没有与“RemoteBut

我有两个Java类,我正试图将它们转换为C。一个是名为RemoteButton的抽象类,另一个派生自名为TVRemoteMute的抽象类。我能够转换抽象RemoteButton类中的大多数成员。一个成员是在TVRemoteMute中实现的抽象ButtonnePressed(),另一个是在基类中实现的虚拟成员ButtonFilePressed()。我的问题是TVRemoteMute类的构造函数。它突出显示了两个词:构造函数名和方法内部的super。构造函数名称错误如下:“没有与“RemoteButton.RemoteButton(EntertmentDevice)”的必需形式参数“newDevice”相对应的给定参数。”“关键字错误读取当前上下文中不存在该名称。我将如何实现这个从Java到C的构造函数,以便我的类可以处理这个构造函数

public abstract class RemoteButton
{
    private EntertainmentDevice theDevice;

    public RemoteButton(EntertainmentDevice newDevice)
    {
        theDevice = newDevice;
    }

    public virtual void buttonFivePressed()
    {
        theDevice.buttonFivePressed();
    }

    public abstract void buttonNinePressed();

 }

public class TVRemoteMute : RemoteButton
{
    public TVRemoteMute(EntertainmentDevice newDevice)
    {
        super(newDevice);
    }

    public override void buttonNinePressed()
    {

        Console.WriteLine("TV was Muted");

    }
}

关键字
super
不在C#中使用;调用基类的构造函数与Java中的不同

tvmotemute
中的构造函数更改为:

public TVRemoteMute(EntertainmentDevice newDevice) : base(newDevice)
{

}
实际上,如果您不在构造函数的主体中执行任何其他操作,我更喜欢这样,但这真的不重要:

public TVRemoteMute(EntertainmentDevice newDevice) : base(newDevice) { }

另一个错误应该在编译后自行修复。

关键字
super
不在C#中使用;调用基类的构造函数与Java中的不同

tvmotemute
中的构造函数更改为:

public TVRemoteMute(EntertainmentDevice newDevice) : base(newDevice)
{

}
实际上,如果您不在构造函数的主体中执行任何其他操作,我更喜欢这样,但这真的不重要:

public TVRemoteMute(EntertainmentDevice newDevice) : base(newDevice) { }

另一个错误应该在编译后自行修复。

base
类中
super
是什么D
public tvmotemute(娱乐设备newDevice):基本设备(newDevice)
在您的
base
类中是什么D
公共电视远程静音(娱乐设备新设备):基本(新设备)