Exemple #1
0
        //Other Methods
        public Person[] GetOldest()
        {
            Person oldestPerson = null;
            People oldestPeople = new People();
            Person currentPerson;

            foreach (DictionaryEntry p in Dictionary)
            {

                currentPerson = p.Value as Person;

                if (oldestPerson == null)
                {
                    oldestPerson = currentPerson;
                    oldestPeople.add(oldestPerson);
                }
                else
                {
                    if (currentPerson > oldestPerson)
                    {
                        oldestPeople.Clear();
                        oldestPeople.add(currentPerson);
                        oldestPerson = currentPerson;
                    }
                    else
                    {
                        if (currentPerson >= oldestPerson)
                        {
                            oldestPeople.add(currentPerson);
                        }
                    }
                }

            }

            Person[] oldestPeopleArray = new Person[oldestPeople.Count];
            int copyIndex = 0;

            foreach (DictionaryEntry p in oldestPeople)
            {
                oldestPeopleArray[copyIndex] = p.Value as Person;
                copyIndex++;
            }

            return oldestPeopleArray;
        }
Exemple #2
0
 //add
 public void add(Person newPerson)
 {
     Dictionary.Add(newPerson.Name, newPerson);
 }