I have a button that by clicking it, a new object is constructed by the name of c1
:
private void addbtn_Click(object sender, EventArgs e)
{
Contact c1 = new Contact(add_name_txtbx.Text,add_num_txtbx.Text);
}
I want to set the name of the new object (c1
) using the text entered in a textbox.
something like:
private void addbtn_Click(object sender, EventArgs e)
{
Contact add_name_txtbx.Text = new Contact(add_name_txtbx.Text,add_num_txtbx.Text);
}
Is it possible? How should I do it?
this is the class:
class Contact
{
public string _name;
public string _number;
public void setName(string Name)
{
_name = Name;
}
public string getName()
{
return _name;
}
public void setNumber(string Number)
{
_number = Number;
}
public string getNumber()
{
return _number;
}
public Contact(string Name, string Number)
{
_name = Name;
_number = Number;
}
}