static void Main(string[] args) { Car myCar = new Car(); //myCar is holding the address of the object instance //"new Car();" in the computer's memory Car.MyMethod(); myCar.Make = "Jaguar"; myCar.Model = "Sting-Ray"; myCar.Year = 2001; myCar.Color = "Silver"; myCar.service(myCar.Year); /* * //Car myThirdCar = new Car("Audi", "Hydragin", 1997, "Red"); //assigning the values while instantiation of "myThirdCar" * * * //illiusion of the class with a object instance myAnotherCar * Car myOtherCar; //Allocating a space(Handle) in memory without creating instance(Bucket) nothing but address * myOtherCar = myCar; //copying the address to myAnotherCar from myCar(giving the power of myCar(created previously)) * Console.WriteLine("Old Value"); * Console.WriteLine("{0} {1} {2} {3}", * myOtherCar.Make, * myOtherCar.Model, * myOtherCar.Year, * myOtherCar.Color); * * * myOtherCar.Year = 1990; * * //first print * Console.WriteLine("New Value"); * Console.WriteLine("{0} {1} {2} {3}", * myCar.Make, * myCar.Model, * myCar.Year, * myCar.Color); * //both are addressing same memory bucket "myAnotherCar" and "myCar" * //.NET framework library has garbage collection * * //removing the reference myAnotherCar from * //the current metohd(cutting a string from a two string baloon); * //more deterministic way to handle references * //myOtherCar = null //same as manual garbage collection as we don't know when .NET framework library will execute garbage collection process through the execution of program * * //Second print(Error will occur "System.NullReferenceException") * * Console.WriteLine("Old Value"); * * Console.WriteLine("{0} {1} {2} {3}", * myOtherCar.Make, * myOtherCar.Model, * myOtherCar.Year, * myOtherCar.Color); * */ Console.ReadLine(); }