目前我正在翻译一个用 java 制作的项目,有一个关于使用父类(super class)/子类的快速问题。基本上,在 java 项目中,我在构造函数中有这样的内容:
public ShipSub(MainGame game, String reference, int x, int y)
{
super(reference,x,y);
this.game=game;
}
我遇到问题的部分是 super(reference,x,y) - 在 xna 中执行此操作的正确方法是什么?我知道使用的是base而不是super,但是我尝试使用base,就像在java代码中使用super一样,但它不起作用。父类(super class)的参数是相同的(这个项目已经在 java 中完成,所以一切都按照我想要的方式工作)我正在使用 xna gamepoint 4.0,如果这有什么区别的话。
谢谢。
最佳答案
public class ShipSub : SomeBaseClass
{
private MainGame game;
public ShipSub(MainGame game, String reference, int x, int y)
: base(game, reference, x, y)
{
this.game = game;
}
}
关于c# - java 和 xna(c#) 中继承语法的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19035954/