Example #1
0
        /// <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)
        {
            // Create a new person and put in an unique Id from nextPersonId();
            int    indexedPersonId = PersonSequencer.getNext();
            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);
        }
Example #2
0
 /// <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();
 }