关于类继承的问题,急,在线等
有个SqlData类
namespace hsj.Base
{
public class SqlData
{
public SqlData(string dbpath)
{
SqlConnectionString = dbpath;
}
private readonly string SqlConnectionString;
}
}
另有一个WebControl类继承SqlData,并和SqlData在同一个解决方案里。
namespace hsj.WebControl
{
public class BindControl:SqlData
{
public BindControl(string dbpath)
{
SqlConnectionString = dbpath;
}
}
}
问题是要怎么初始化WebControl的构造函数才正确呢,我现在的写法报错是:
错误 1 “SqlData”方法没有采用“0”个参数的重载 F:\mysoft\vs2005\hsj\WebControl\BindControl.cs 10 16 WebControl
错误 2 当前上下文中不存在名称“SqlConnectionString” F:\mysoft\vs2005\hsj\WebControl\BindControl.cs 12 13 WebControl
------解决方案--------------------namespace hsj.WebControl
{
public class BindControl:SqlData
{
public BindControl(string dbpath) : base(dbpath)
{
}
}
}
------解决方案--------------------namespace hsj.Base
{
public class SqlData
{
public SqlData(string dbpath)
{
SqlConnectionString = dbpath;
}
protected readonly string SqlConnectionString;
}
}
namespace hsj.WebControl
{
public class BindControl:SqlData
{
public BindControl(string dbpath):base(dbpath)
{
}
}
}
------解决方案--------------------支持