小编Sha*_*yte的帖子

C#调用基础构造函数

我已经谷歌"调用基础构造函数",我没有得到我需要的答案.

这是我的构造函数;

public class defaultObject
{
    Vector2 position;
    float rotation;
    Texture2D texture;

    public defaultObject(Vector2 nPos, float nRotation, Texture2D nTexture)
    {
        position = nPos;
        rotation = nRotation;
        texture = nTexture;
    }
}
Run Code Online (Sandbox Code Playgroud)

现在我有了这个,我想继承构造函数及其所有工作.这是我期望做的;

public class Block : defaultObject
{
    // variables inherited from defaultObject
    public Block : defaultObject; //calls defaultObject constructor
}
Run Code Online (Sandbox Code Playgroud)

为什么我不能这样做?

c# inheritance constructor

1
推荐指数
1
解决办法
123
查看次数

标签 统计

c# ×1

constructor ×1

inheritance ×1