private void btnSaveContact_Click(object sender, EventArgs e) { string[] contact = txtNewContact.Text.Split(','); if (contact.Length < 3) { lblError.Text = "Error! <firstname>,<lastname>,<phonenumber>"; return; } string tmpFirstName = contact[0], tmpLastName = contact[1], tmpNumber = contact[2]; if (chklsSecret.Checked) { SecretContact tmpSecretContactToAdd = new SecretContact(tmpFirstName, tmpLastName, tmpNumber); myPhoneBook.AddContact(tmpSecretContactToAdd); } else { Contact tmpContactToAdd = new Contact(tmpFirstName, tmpLastName, tmpNumber); myPhoneBook.AddContact(tmpContactToAdd); } txtNewContact.Text = ""; lblError.Text = ""; UpdateContacts(); }
public void RemoveContact(Contact contactToRemove) { contacts.Remove(contactToRemove); }
public void AddContact(Contact contactToAdd) { contacts.Add(contactToAdd); }