public Person Copy() { Person newPerson = new Person(); newPerson.FormPerson(id, name, lastName); for (int i = 0; i < phones.Count; i++) { newPerson.phones.Add(phones[i].Copy()); } return newPerson; }
public Person Parse(string line) { Person person = new Person(); person.FormPerson(Convert.ToInt32(line.Split('=')[0]), line.Split('=')[1], line.Split('=')[2]); string[] phones = line.Split('='); for (int i = 3; i < phones.Length; i++) { Phone phone = new Phone(phones[i]); person.AddPhone(phone); } return person; }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { int rowIndex = dataGridView1.SelectedRows[0].Index; selectedPerson = persons[rowIndex].Copy(); newPerson=persons[rowIndex].Copy(); }