public Person NewPerson(string firstName, string lastName) { Person person = new Person(PersonSequencer.nextPersonID(), firstName, lastName); Array.Resize(ref personList, personList.Length + 1); personList[personList.Length - 1] = person; return(person); }
/// <summary> /// AddPerson creates a new person and inserts it into the existing array of /// persons in the people collection. /// </summary> /// <param name="firstName">The actual first name of person.</param> /// <param name="lastName">The actual last name of person.</param> /// <returns>Returns the object of the created person.</returns> public Person AddPerson(string firstName, string lastName) { int indexedPersonId = PersonSequencer.nextPersonId(); Person newPerson = new Person(indexedPersonId, firstName, lastName); // Now extend the Array by one so insert is possible int lengthOfField = myPeople.Length; Array.Resize(ref myPeople, lengthOfField + 1); myPeople[lengthOfField] = newPerson; return(newPerson); }
/// <summary> /// Clear method discards the old collection of people and creates a new empty one. /// Note that the Id handler will also reset! /// </summary> public void Clear() { myPeople = new Person[0]; PersonSequencer.reset(); }