This question already has answers here:
Calling the base constructor in C#

(13 个回答)


6年前关闭。




我目前有一个抽象类,例如
abstract class Users
{
    private List<string> SelectedUsers;

    public Users(List<string> SelectedUsers)
    {
        this.SelectedUsers = SelectedUsers;
    }
}

和一个子类
class UsersTypeOne : Users
{
     //What do I put here in order to call the constructor in the abstract class
}

最佳答案

class UsersTypeOne : Users
{
    public UsersTypeOne(List<string> SelectedUsers)
        : base(SelectedUsers)
    {

    }
}

关于c# - 让构造函数从抽象类扩展到子类?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24890994/

10-09 15:33