我很新的C#,我不明白我在做什麼錯了,這裏是我的代碼:C#錯誤:不包含一個構造函數參數0
public class Client
{
public int Code { get; set; }
public string Name { get; set; }
public int Phone { get; set; }
public string Email { get; set; }
public Client (int code, string name, int phone, string email)
{
Code = code;
Name = name;
Phone = phone;
Email = email;
}
public override string ToString()
{
return string.Format("Code {0} | Name: {1} | Phone: {2} | Email{3}", Code, Name, Phone, Email);
}
}
public frm_cadastro()
{
InitializeComponent();
}
public List<Client> clieList = new List<Client>();
private void btn_add_Click(object sender, EventArgs e)
{
clieList.Add(new Client() //This is where the error is
{
Code = Convert.ToInt32(txt_cod.Text),
Name = txt_name.Text,
Phone = Convert.ToInt32(txt_phone.Text),
Email = txt_email.Text,
});
此代碼起源從以前的問題,我問我如何加載我的列表數據到我的文本框。
你的客戶端類需要4個參數,但要與'新客戶創建()'嘗試'新的客戶端(Convert.ToInt32(txt_cod.Text,txt_name.Text ........)'閱讀一些關於c#的文檔可能會有所幫助.... – 2014-10-18 19:49:14