public override void print(PdaItem pda) { if(this != null) System.Console.WriteLine("NOT NULL"); else System.Console.WriteLine("NULL"); }
public static void Main() { Contact contact = new Contact(); PdaItem item = contact; item.Name = "bb aa"; System.Console.WriteLine("{0} {1}", contact.FirstName, contact.LastName); }
// Contact contact = new Contact(); // contact.Name = "park"; // Contact contact2 = new Contact(); // PdaItem item = contact2; // contact = (Contact)item; public static void Main() { PdaItem[] pda = new PdaItem[3]; Contact contact = new Contact("Sherlock Holmes"); contact.Address = "221B Baker Street, London, England"; pda[0] = contact; }
public static void List(PdaItem[] items) { // Implemented using polymorphism. The derived // type knows the specifics of implementing // GetSummary(). foreach(PdaItem item in items) { Console.WriteLine("________"); Console.WriteLine(item.GetSummary()); } }
static void Main() { // Allowed in C# 4.0 Pair <Contact> contacts = new Pair <Contact>( new Contact("Princess Buttercup"), new Contact("Inigo Montoya")); IReadOnlyPair <PdaItem> pair = contacts; PdaItem pdaItem1 = pair.First; PdaItem pdaItem2 = pair.Second; }
static void Main(string[] args) { Contact contact = new Contact(); /*clases derivadas pueden convertirse a clases base de forma implicita*/ PdaItem item = contact; /*clases base pueden convertirse a clases derivadas de forma explicita*/ contact = (Contact)item; contact.Mostrar(); }
public static void Main() { // Derived types can be implicitly converted to // base types Contact contact = new Contact(); PdaItem item = contact; // ... // Base types must be cast explicitly to derived types contact = (Contact)item; // ... }
public static void Main() { PdaItem[] pda = new PdaItem[3]; Contact contact = new Contact("sherlock holmes"); contact.Address = "221b baker street,london,england"; pda[0] = contact; Appointment appointment = new Appointment("soccer tournament"); appointment.StartDateTime = new DateTime(2008, 7, 18); appointment.EndDateTime = new DateTime(2008, 7, 19); appointment.Location = "estadio da machava"; pda[1] = appointment; contact = new Contact("hercule poirot"); contact.Address = "apt 56b,whitehaven mansions,sandhurst sq,london"; pda[2] = contact; List(pda); }
public static void Main() { PdaItem[] pda = new PdaItem[3]; Contact contact = new Contact("Sherlock Holmes"); contact.Address = "221B Baker Street, London, England"; pda[0] = contact; Appointment appointment = new Appointment("Soccer tournament"); appointment.StartDateTime = new DateTime(2008, 7, 18); appointment.EndDateTime = new DateTime(2008, 7, 19); appointment.Location = "Estádio da Machava"; pda[1] = appointment; contact = new Contact("Anne Frank"); contact.Address = "Apt 56B, Whitehaven Mansions, Sandhurst Sq, London"; pda[2] = contact; List(pda); }
public abstract void print(PdaItem pda);