-4

なぜこのエラーが発生するのかわかりません。コードが非常に多く、何が間違っているのかがわからないので、すべてのファイルへのリンクを投稿します。誰かがこのエラー「 'Customer' does not contain a constructor that takes 5 arguments」を受け取った理由を理解するかもしれません...これで立ち往生している1時間...これはファイルです エラーはページ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 に答える