static void Main(string[] args)
 {
     #region CreateGenericCar
     // var keyword INFER TYPE FROM RIGHT ie CAR
     // car01 INSTANCE ie particular object created
     // Car = TEMPLATE USED
     // () run a METHOD when calling 'new' keyword  //  Constructor Method
     var car01 = new Car();
     car01.Make = "Mercedes";
     for (int i = 0; i < 1000; i++)
     {
         // CREATE 1000 CARS!
         var car = new Car();
     }
     var newCar = new Car();
     Console.WriteLine($"Initial Speed {newCar.Speed}");
     newCar.Speed++;
     newCar.Speed++;
     Console.WriteLine($"Final Speed{newCar.Speed}");
     var car02 = new Car("Mercedes", "C220", "silver", 2200);
     #endregion CreateGenericCar
     #region CreateS220Car
     var s220car01 = new S220();  // constructors NOT INHERITED
     var car04     = new S220("blue", 2200);
     Console.WriteLine($"new car {car04.Make} {car04.Model} is {car04.Color} ");
     #endregion CreateS220Car
 }
Пример #2
0
 static void Main(string[] args)
 {
     #region CreateGenericCar
     //var keyword INFER TYPE FROM RIGHT ie Car
     //car01 INSTANCE ie particular object created
     //Car is template used
     //() run a method when calling 'new' keyword // constructor
     var car01 = new Car();
     car01.Make = "Mclaren";
     for (int i = 0; i < 1000; i++)
     {
         //CREATE 1000 CARS
         var car = new Car();
     }
     var newCar = new Car();
     Console.WriteLine($"Initial Speed {newCar.Speed}");
     newCar.Speed++;
     newCar.Speed++;
     Console.WriteLine($"Final Speed{newCar.Speed}");
     var car02 = new Car("Mclaren", "P1", "Orange", 2200, 200);
     #endregion
     #region CreateS220Car
     var s220car01 = new S220("black", 2000);  // Constructors NOT INHERITED
     #endregion CreateS220Car
 }