Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Car c = new Car("Frank", 50, "red");
            
            c.DisplayStats();

            Garage g = new Garage();
            Console.WriteLine("=> auto properies are initialized to defaults");
            Console.WriteLine("int: {0}", g.NumberOfCars);            
            Console.WriteLine("object is null {0}", g.MyAuto == null);
            Console.ReadLine();
        }   
Exemplo n.º 2
0
 static void Main(string[] args)
 {
     Car c = new Car();
     c.PetName = "Frank";
     c.Speed = 55;
     c.Color = "red";
     Console.WriteLine("your car is named:{0}",c.PetName);
     c.DisplayStats();
     Garage g = new Garage();
     g.myAuto = c;
     Console.WriteLine("Number of cars:{0}",g.NumberOfCars);
     Console.WriteLine(g.myAuto.PetName);
     Console.ReadLine();
 }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Automatic Properties *****\n");
            Car c = new Car();
            c.PetName = "Frank";
            c.Speed = 55;
            c.Color = "Red";

            Console.WriteLine("Your car is named {0}? That's odd...", c.PetName);
            c.DisplayStats();

            Garage g = new Garage();
            g.MyAuto = c;

            Console.WriteLine("Number Of Cars in garage: {0}", g.NumberOfCars);

            Console.WriteLine("Your car is named: {0}", g.MyAuto.PetName);

            Console.ReadLine();
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Automatic Properties *****\n");

            // Make a car.
            Car c = new Car();
            c.PetName = "Frank";
            c.Speed = 55;
            c.Color = "Red";
            c.DisplayStats();

            // Put car in the garage.
            Garage g = new Garage();
            g.MyAuto = c;
            Console.WriteLine("Number of Cars in garage: {0}", g.NumberOfCars);
            Console.WriteLine("Your car is named: {0}", g.MyAuto.PetName);

            // lets dispose it
            g.Dispose();

            Console.ReadLine();
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with auto props *****\n");
            Car c = new Car();
            c.PetName = "Frank";
            c.Speed = 55;
            c.Color = "Red";
            //Console.WriteLine("Your car is named {0}? That's odd...",c.PetName);
            c.DisplayStats();

            //put car in the garage.
            Garage g = new Garage();
            g.MyAuto = c;
            //0OK, prints default value of 0.
            Console.WriteLine("Number of cars in garage: {0}", g.NumberOfCars);
            Console.WriteLine("Your car is named: {0}", g.MyAuto.PetName);
            

            //runtime error! backing field is currently null!
            //Console.WriteLine(g.MyAuto.PetName);

            Console.ReadLine();
        }
Exemplo n.º 6
0
        private static void Main(string[] args)
        {
            Console.WriteLine("***** Fun with Automatic Properties *****\n");

            var c = new Car()
            {
                PetName = "Frank",
                Speed   = 55,
                Color   = "Red"
            };

            Console.WriteLine("Your car is named {0}? That't odd...", c.PetName);
            c.DisplayStats();

            var g = new Garage()
            {
                MyAuto = c
            };

            Console.WriteLine("Number of Cars: {0}", g.NumberOfCars);
            Console.WriteLine("Your car is named: {0}", g.MyAuto.PetName);

            Console.ReadLine();
        }