-4

我不知道为什么我会收到这个错误。由于代码很多,而且我不明白可能有什么问题,我发布了所有文件的链接。如果有人可能会弄清楚为什么我会收到此错误“'客户'不包含带有 5 个参数的构造函数”......一个小时我被困在这个......这是文件 错误在 page book.aspx

if (Page.IsPostBack) 
{ 
   Customer c1 = new Customer(txtFirstname.Text, txtLastname.Text, txtAddress.Text, txtZip.Text, txtCity.Text); 
   Pet p1 = new Pet(txtSpecies.Text, txtName.Text,c1); 
   service.pets.Add(p1); 
}

客户->

public Customer(int customerId, string firstname, string lastname, string address, string zipcode, string city, string email, string phone) 
     : base(firstname, lastname) 
{ 
    this.firstname = firstname; 
    this.lastname = lastname; 
} 
4

1 回答 1

0

Customer 类的构造函数是 -

public Customer(int customerId, string firstname, string lastname,
                string address, string zipcode, string city, string email,
                string phone)

从 Book.aspx.cs 您正在创建实例,例如 -

Customer c1 = new Customer(txtFirstname.Text, txtLastname.Text,
            txtAddress.Text, txtZip.Text, txtCity.Text);

将其替换为 -

Customer c1 = new Customer(txtFirstname.Text, txtLastname.Text,
            txtAddress.Text, txtZip.Text, txtCity.Text, string.Empty,
              string.Empty, string.Empty);
于 2012-10-27T13:40:38.080 回答