构造函数的执行顺序问题!◎◎
hccl 2007-09-10 10:28:45 学习语法时书上说:
构造函数执行顺序是:system.object->基类匹配构造函数->派生类构造器...
我写了如下代码,为何无法执行基类构造函数
基类:
public class LoginCheck
{
protected string username, userpassword;
protected string tablename;
protected string test;
public LoginCheck(string userId, string userPwd,string userinfotable)
{
username = userId; //设置断点
userpassword = userPwd;
tablename = userinfotable;
test = "gogo";
}
//其他代码
}
派生类:
public class UserLoginCheck : LoginCheck
{
public UserLoginCheck(string userId, string userPwd, string userinfotable)
{
username = userId;
userpassword = userPwd;
tablename = userinfotable;
}
}
执行构造函数代码:
UserLoginCheck ulc = new UserLoginCheck("a", "b", "c");
为什么没有先执行基类的匹配签名的构造函数LoginCheck()?
导致我无法在派生类中取到变量test的值