static void Main(string[] args) { PersonCollection myPeople = new PersonCollection(); myPeople["Homer"] = new Person("Homer", "Simpson", 40); myPeople["Marge"] = new Person("Marge", "Simpson", 38); Person homer = myPeople["Homer"]; Console.WriteLine(homer); Console.ReadLine(); }
static void Main( string[] args ) { Console.WriteLine("***** Fun with Indexers *****\n"); PersonCollection myPeople = new PersonCollection(); myPeople["Homer"] = new Person("Homer", "Simpson", 40); myPeople["Marge"] = new Person("Marge", "Simpson", 38); // Get "Homer" and print data. Person homer = myPeople["Homer"]; Console.WriteLine(homer.ToString()); Console.ReadLine(); }
static void Main(string[] args) { Console.WriteLine("***** Fun with Indexers *****\n"); PersonCollection myPeople = new PersonCollection(); myPeople["Homer"] = new Person("Homer", "Simpson", 40); myPeople["Marge"] = new Person("Marge", "Simpson", 38); // Get "Homer" and print data. Person homer = myPeople["Homer"]; Console.WriteLine(homer.ToString()); Console.ReadLine(); }
static void Main(string[] args) { Console.WriteLine("Fun with tring indexers"); PersonCollection myPeople = new PersonCollection(); myPeople["Homer"] = new Person("Homer", "Simpson", 40); myPeople["Marge"] = new Person("Marge", "Simpson", 38); foreach (var person in myPeople) { Console.WriteLine(person.ToString()); } //get homer and print data Person homer = myPeople["Homer"]; Console.WriteLine(homer.ToString()); Console.Read(); }