static void Main(string[] args) { // ==== Inheritance - Tính Kế Thừa ==== // is-a relationship Samsung S8 = new Samsung(); S8.Name = "Samsung Galaxy S8"; // S8.OS = "Android"; S8.Call(); System.Console.WriteLine(S8.OS); IPhone iphone7 = new IPhone(); iphone7.Siri(); System.Console.WriteLine(iphone7.OS); // ==== Polymorphism - Tính Đa Hình ==== S8.Text(); iphone7.Text(); // handle data Smartphone phone1 = new Samsung(); phone1.Call(); Smartphone phone2 = new IPhone(); phone2.Call(); Smartphone[] dataArray = new Smartphone[] { phone1, phone2 }; // ==== Abstract Class ==== Cat kitty = new Cat(); kitty.MakeSound(); }
static void Main() { /* Apple apple = new Apple(); * apple.MobileStandardEmployee(); * apple.Call(); * Samsung samsung = new Samsung(); * samsung.Call();*/ //run time polymorphism or Dynamic polymorphism MobileStandard mobileStandard; mobileStandard = new Apple(); mobileStandard.Call(); //call Method in Apple Console.WriteLine(mobileStandard.Terms()); mobileStandard = new Samsung(); mobileStandard.Call(); //Call Method in samsung Console.WriteLine(mobileStandard.Terms()); Console.Read(); }
// creating an abstract class this abstract class must now make object as subch static void Main() { /* * Methods 1 * Apple ap = new Apple(); * ap.Call(); */ MobileStandart mobileStandart; mobileStandart = new Apple(); mobileStandart.Call(); // Will talk about Aple mobileStandart = new Samsung(); mobileStandart.Call(); // call out for samsungs mobileStandart.Term(); // will show samsung terms Console.ReadLine(); }