我很新的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