Esempio n. 1
0
        public static void Main(String[] args)
        {
            // Constructor creates new instance & initializes it
            Car myCar = new Car();

            Console.WriteLine("Initial make is {0}", myCar.Make);

            Car myOtherCar = new Car("Ford", 1998, 2500.00);

            myOtherCar.PrintDetails();

            // Typically, the properties of the object would be set via some
            // // interface, and saved to a file or database
            myCar.Make          = "Toyota";
            myCar.Model         = "Camry";
            myCar.Color         = "White";
            myCar.OriginalPrice = 35000;
            myCar.Year          = 2007;

            // before calling doByValue
            myCar.PrintDetails();
            Console.WriteLine("Its value is {0:C}", getMarketValue(myCar));


            // call doByValue
            doByValue(myCar);
            // after calling doByValue
            myCar.PrintDetails();
            Console.WriteLine("Its value is {0:C}", getMarketValue(myCar));


            // call doByRef
            doByRef(ref myCar);
            // after calling doByValue
            myCar.PrintDetails();
            Console.WriteLine("Its value is {0:C}", getMarketValue(myCar));
        }