【问题标题】:Invalid token 'base' in class, struct, or interface member declaration类、结构或接口成员声明中的标记“基”无效
【发布时间】:2014-04-07 21:02:43
【问题描述】:

我不确定问题出在哪里,但我想要做的是将参数从派生类传递给基构造函数

错误:

Invalid token 'base' in class, struct, or interface member declaration

这是我的base class code:

public class EmployeeRegistrationBase
{
    //constructor
    public EmployeeRegistrationBase(string methodName)
    {
       //more code...
    }
}

这是我的derived class:

public class USER_REG_LOG_INFO  : base(EmployeeRegistrationBase("some_method_name"))
{
     //more code....
}

【问题讨论】:

  • 你应该在构造函数上使用base......
  • 这不是有效的语法。你想做什么?

标签: c# abstract-class derived-class base-class


【解决方案1】:

您的继承语法和构造函数传递不正确。试试这个:

public class USER_REG_LOG_INFO  : EmployeeRegistrationBase
{
     public USER_REG_LOG_INFO() : base("some_method_name")
     {
     }

     //more code....
}

【讨论】:

    猜你喜欢
    • 2013-01-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-22
    • 2016-07-10
    • 1970-01-01
    • 2012-06-19
    • 2014-02-02
    相关资源
    最近更新 更多