Exemplo n.º 1
0
        public static void RunBookTest(bool isRun)
        {
            if (!isRun)
            {
                return;
            }

            Console.WriteLine("Hello World!");

            int i = 10;
            int j = 10;

            Console.WriteLine("object.ReferenceEquals(i,j) = {0}", object.ReferenceEquals(i, j));

            int iValue = 10;
            //Boxing int value
            object oValue = iValue;

            Console.WriteLine("Unboxing oValue result = " + (int)oValue);
            //执行到下面的代码会报错,提示非法的类型转换
            //float fValue = (float)oValue;
            //Console.WriteLine("Unboxing oValue result = " + fValue);

            string str1 = "hello";
            string str2 = "hello";

            Console.WriteLine("object.ReferenceEquals(str1,str2) = {0}",
                              object.ReferenceEquals(str1, str2));

            string temp = "before changed";

            ChangeStr(temp);
            Console.WriteLine(temp);

            TestUnsafe(false);
            TestInheritance.RunTest(false);

            Person person1 = new Person("God1");

            person1.Print();
            Person person2 = person1.Clone() as Person;

            person2.Name = "God2";
            Console.WriteLine(person1.Name);
            Console.WriteLine(person2.Name);
            //person.PrintClassName();
            //Person.PrintClassName();

            //Global.PrintClassName();

            SomeValues tmp = SomeValues.Value_0;

            Console.WriteLine(tmp.ToString());
            Console.WriteLine(10.GetType ());

            OuterClass outer_obj = new OuterClass();

            outer_obj.ToString();
            OuterClass.NestedClass nested_class = new OuterClass.NestedClass();
            nested_class.PrintOuterObjCount();
            nested_class.PrintNestedObjCount();

            TestStaticMember(false);
            TestFuncArgTransmit(false);
            TestArgPass.RunTest(false);

            TestFraction.RunTest(false);
            TestStruct.RunTest(false);

            TestInterface.RunTest(false);
            TestDispose.RunTestDispose(false);
            TestArray.RunTest(true);

            TestString.RunTest(false);
            TestDelegateEvent.RunTest(false);
            //TestAttribute.RunTest (true);
        }
Exemplo n.º 2
0
 public static void RunTest()
 {
     OuterClass obj = new OuterClass();
 }