Beispiel #1
0
        static void Main(string[] args)
        {
            StructArray <int> a = new StructArray <int>(3);

            a.Array[0] = 0;
            a.Array[1] = 1;
            a.Array[2] = 2;

            RefArray <StructArray <double> > b = new RefArray <StructArray <double> >(3);

            b.Array[0] = new StructArray <double>(5);
            b.Array[1] = new StructArray <double>(10);
            b.Array[2] = new StructArray <double>(1005);

            BaseArray <Base> c = new BaseArray <Base>(3);

            c.Array[0] = new Base();
            c.Array[1] = new Derived();
            c.Array[2] = CreateInstance <Base>();

            BaseArray <Derived> d = new BaseArray <Derived>(3);

            d.Array[0] = new Derived(); // Base 형식은 여기에 할당 할 수 없다.
            d.Array[1] = CreateInstance <Derived>();
            d.Array[2] = CreateInstance <Derived>();

            BaseArray <Derived> e = new BaseArray <Derived>(3);

            e.CopyyArray <Derived>(d.Array);
        }
        static void Main(string[] args)
        {
            StructArray <int> a = new StructArray <int>(3);

            a.Array[0] = 0;
            a.Array[1] = 1;
            a.Array[2] = 2;

            RefArray <StructArray <double> > b = new RefArray <StructArray <double> >(3);

            b.Array[0] = new StructArray <double>(5);
            b.Array[1] = new StructArray <double>(10);
            b.Array[2] = new StructArray <double>(1005);

            BaseArray <Base> c = new BaseArray <Base>(3);

            c.Array[0] = new Base();
            c.Array[1] = new Derived();
            c.Array[2] = CreateInstance <Base>();

            BaseArray <Derived> d = new BaseArray <Derived>(3);

            d.Array[0] = new Derived(); // Base 형식은 여기에 할당 할 수 없다.
            d.Array[1] = CreateInstance <Derived>();
            d.Array[2] = CreateInstance <Derived>();

            BaseArray <Derived> e = new BaseArray <Derived>(3);

            e.CopyyArray <Derived>(d.Array);

            Console.WriteLine("1.출력구문이 따로 없으니 따로 출력 구문을 구현해 보자.");
            Console.WriteLine("2.인터페이스를 구현하는 일반화 코드가 없으니 이것 또한 구현해 보자.");
            Console.ReadKey();
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            StructArray <int> a = new StructArray <int>(3);

            a.Array[0] = 0;
            a.Array[1] = 1;
            a.Array[2] = 2;
            for (int i = 0; i < a.Array.Length; i++)
            {
                Console.WriteLine(a.Array[i]);
            }


            RefArray <StructArray <double> > b = new RefArray <StructArray <double> >(3);

            b.Array[0] = new StructArray <double>(5);
            b.Array[1] = new StructArray <double>(10);
            b.Array[2] = new StructArray <double>(1005);
            Console.WriteLine();
            for (int i = 0; i < b.Array.Length; i++)
            {
                Console.WriteLine(b.Array[i]);
            }

            BaseArray <Base> c = new BaseArray <Base>(3);

            c.Array[0] = new Base();
            c.Array[1] = new Derived();
            c.Array[2] = CreateInstance <Base>();
            Console.WriteLine();
            for (int i = 0; i < c.Array.Length; i++)
            {
                Console.WriteLine(c.Array[i]);
            }

            BaseArray <Derived> d = new BaseArray <Derived>(3);

            d.Array[0] = new Derived(); // Base 형식은 여기에 할당 할 수 없다.
            d.Array[1] = CreateInstance <Derived>();
            d.Array[2] = CreateInstance <Derived>();

            Console.WriteLine();
            for (int i = 0; i < d.Array.Length; i++)
            {
                Console.WriteLine(d.Array[i]);
            }

            BaseArray <Derived> e = new BaseArray <Derived>(3);

            e.CopyyArray <Derived>(d.Array);
            Console.WriteLine();
            Console.WriteLine(e.Array);

            InterfaceArray <intf> f = new InterfaceArray <intf>(3);

            Console.WriteLine();
            Console.WriteLine(f.Array);
        }