Esempio n. 1
0
        public static void Main()
        {
            Car myCar=new Car("Rowe");
            Car heCar=new Car("BYD", 3);
            Car youCar=new Car();

            Bike myBike;  //#important# If Bike were a class, this produce a compile error, because myBike contain a uninitialized reference �� an address that points nowhere; Ȼ������struct��˵�������������Ѿ���stack�Ϸ����˿ռ�
            myBike.nWheels = 2;
            //string foo = myBike.descript; /*everything must be initialized before use. A struct is considered fully initialized either when the new operator called or when values be individually assigned to all its fields*/
            Console.WriteLine(youCar.ToString()); //ToString()���麯��, If you don��t override ToString() in classes that you define, your classes inherit the System.Object implementation, which displays the name of the class.
        }
Esempio n. 2
0
 public static void Main()
 {
     Car myCar=new Car("Rowe");
     Car youCar;
     Bike myBiker;
 }