示例#1
0
        public void a()
        {
            ValueTypeVSRefType mainClass = new ValueTypeVSRefType();
            MyClass            myClass   = new MyClass();  //3
            MyStruct           myStruct  = new MyStruct(); //3

            myClass.x  = 9;
            myStruct.x = 9;
            System.Console.WriteLine("*** Before ***");
            System.Console.WriteLine("Class value is {0}", myClass.x);
            System.Console.WriteLine("Struct value is {0}", myStruct.x);
            mainClass.inc(myClass, ref myStruct); //4
            System.Console.WriteLine("*** After ***");
            System.Console.WriteLine("Class value is {0}", myClass.x);
            System.Console.WriteLine("Struct value is {0}", myStruct.x);
            System.Console.ReadLine();
        }
        static void Main(string[] args)
        {
            welcomeMethod();
            //Console.ReadKey();

            Student s1 = new Student();

            s1.Name = "Cinderella";
            s1.Age  = 18;
            Student S3;
            Student s2;

            s2 = s1;
            Console.WriteLine(s1.Name + s1.Age);
            Console.WriteLine(s2.Name + s2.Age);

            ValueTypeVSRefType myTest = new ValueTypeVSRefType();

            int[] arr = new int[30];

            for (int i = 0; i < arr.Length; i++)
            {
                arr[i] = i * 2;
            }



            foreach (int i in arr)
            {
                Console.WriteLine(i);
            }


            myTest.a();

            Console.ReadKey();
        }