public static void TestContactInfo() { Phone p = new Phone(); p.PhoneNum = 7551031; p.AreaCode = 801; ContactInfo c1 = new ContactInfo("*****@*****.**", new Address("007", "Bond City", "Utah", 84022, "no23778"), new Phone { AreaCode = 646, PhoneNum = 4351234 }); // Console.WriteLine(c1); ContactInfo johnContacntInfo = new ContactInfo("*****@*****.**", new Address("41 st", "NY", "NY", 10030, "24A"), new Phone { AreaCode = 654, PhoneNum = 8270061 }); ContactInfo mariaContactInfo = new ContactInfo("*****@*****.**", new Address("77 st", "NY", "NY", 10030, "10A"), new Phone { AreaCode = 654, PhoneNum = 8270061 }); Dictionary<string, ContactInfo> contacts = new Dictionary<string, ContactInfo> { ["John"] = johnContacntInfo, ["Maria"] = mariaContactInfo, ["Ben"] = new ContactInfo("*****@*****.**", new Address("5th Ave", "Seattle", "WA", 89125, "12B"), new Phone { AreaCode = 206, PhoneNum = 1234543 }) }; foreach (var entry in contacts) { Console.WriteLine(entry.Key); Console.WriteLine(entry.Value); Console.WriteLine(); Console.WriteLine(); } }
public ContactInfo(string email, Address address, Phone phone) { this.Email = email; this.Address = address; this.Phone = phone; }
private static void TestPhone() { Phone p1 = new Phone(); Console.WriteLine("p1: " + p1); Phone p2 = new Phone { AreaCode = 801, PhoneNum = 1234 }; Console.WriteLine("p2: " + p2); Console.WriteLine(); }