Exemple #1
0
 //Main_10_1_2
 public static void Main()
 {
     MyArray<int> myIntArr = new MyArray<int>();
     myIntArr.Add(123);
     Console.WriteLine(myIntArr[0]);
     //��֤���Ͱ�ȫ���޷�ͨ��������
     //string myItem = (string)myIntArr[0];
     MyArray<string> myStringArr = new MyArray<string>();
     myStringArr.Add("222");
     Console.WriteLine(myStringArr[0]);
 }
Exemple #2
0
        public static void Main()//Main_10_1_2
        {
            MyArray <int> myIntArr = new MyArray <int>();

            myIntArr.Add(123);
            Console.WriteLine(myIntArr[0]);
            //保证类型安全,无法通过编译检测
            //string myItem = (string)myIntArr[0];
            MyArray <string> myStringArr = new MyArray <string>();

            myStringArr.Add("222");
            Console.WriteLine(myStringArr[0]);
        }
Exemple #3
0
        //Main_10_1_1
        public static void Main_10_1_1()
        {
            MyArray myArr = new MyArray();

            //���Խ����κ����͵�Ԫ��
            myArr.Add("Hello, world");
            myArr.Add(123);
            myArr.Add(new MyArray());

            Console.WriteLine(myArr[2]);

            //DZ�ڵ����Ͱ�ȫ����
            Int32 myItem = (Int32)myArr[0];
            Console.WriteLine(myItem);
        }
Exemple #4
0
        public static void Main_10_1_1()//Main_10_1_1
        {
            MyArray myArr = new MyArray();

            //可以接受任何类型的元素
            myArr.Add("Hello, world");
            myArr.Add(123);
            myArr.Add(new MyArray());

            Console.WriteLine(myArr[2]);

            //潜在的类型安全问题
            Int32 myItem = (Int32)myArr[0];

            Console.WriteLine(myItem);
        }