using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace UsingCollectionsDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            SortedList people = new SortedList();
            people.Add("Richard", new Person { Name = "Richard", Age= 32 });
            Person louisa = new Person()
            {
                Name = "Louisa",
                Age = 25
            };
            people.Add(louisa.Name, louisa);

            Person personFromCollection = (Person)people["Richard"];

            if (personFromCollection != null)
            {
                Console.WriteLine("Name: {0}, Age: {1}", personFromCollection.Name, personFromCollection.Age.ToString());
            }

            Console.ReadLine();

            foreach (DictionaryEntry entry in people)
            {
                Person person = (Person)entry.Value;
                Console.WriteLine("Name: {0}, Age: {1}", person.Name, person.Age.ToString());
            }

            Console.ReadLine();
        }
    }
}
