static void Main(string[] args) { //New instance or object of Class Car Car myCar = new Car(); myCar.Make = "BMW"; myCar.Model = "745li"; myCar.Color = "Black"; myCar.Year = 2005; //New instance/Object of Class Truck Truck myTruck = new Truck(); myTruck.Make = "Ford"; myTruck.Model = "F950"; myTruck.Year = 2006; myTruck.Color = "Black"; myTruck.TowingCapacity = 1200; myCar.PrintMe(); myTruck.PrintMe(); Console.ReadLine(); }
static void Main(string[] args) { NewCar tesla = new NewCar(); tesla.Model = "Model S"; tesla.Price = 90000m; tesla.VIN = "SC54SD5F4SDF5S5SD"; UsedCar usedToyota = new UsedCar(); usedToyota.Price = 20000m; usedToyota.CalculateTax(); CertifiedUsedCar cuLexus = new CertifiedUsedCar(); NewCar[] newCars = new NewCar[] { tesla, /*usedToyota,*/ }; //No no bc the toyota isn't a NewCar Car[] newerCars = new Car[] { tesla, usedToyota, cuLexus }; //sisisi bc they're all cars Car[] inventory = new Car[] { new UsedCar { VIN = "65465AS4D6F5AS4FD", Price = 17000m }, new CertifiedUsedCar { VIN = "52152452152452451", Price = 17000m }, new NewCar { VIN = "22452145259554525", Price = 44000m }, new UsedCar { VIN = "s98sdf8ds9f89s9d6", Price = 12000m }, new UsedCar { VIN = "asdfasd2342342345", Price = 11000m } }; decimal total = 0; foreach(Car car in inventory) { if (car is UsedCar) { total += car.Price; } } Console.WriteLine("Total inventory value: " + total.ToString("c")); Console.ReadLine(); }
private static void someMethod(Car car) { Console.WriteLine("From someMethod: {0}", car.Make); }