Esempio n. 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();
            d.Array[1] = CreateInstance <Derived>();
            d.Array[2] = CreateInstance <Derived>();

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

            e.CopyArray <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();
        }
Esempio n. 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);
        }
Esempio n. 4
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;

            Console.WriteLine(a.Array[0]);
            Console.WriteLine(a.Array[1]);
            Console.WriteLine(a.Array[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);

            Console.WriteLine(b.Array[0]);
            Console.WriteLine(b.Array[1]);
            Console.WriteLine(b.Array[2]);

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

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

            Console.WriteLine(c.Array[0]);
            Console.WriteLine(c.Array[1]);
            Console.WriteLine(c.Array[2]);

            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(d.Array[0]);
            Console.WriteLine(d.Array[1]);
            Console.WriteLine(d.Array[2]);

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

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

            Console.WriteLine(e.Array[0]);
            Console.WriteLine(e.Array[1]);
            Console.WriteLine(e.Array[2]);
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            StructArray <int> a = new StructArray <int>(3);

            //RefArray<string> b = new RefArray<string>(3);

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

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

            BaseArray <Derived> d = new BaseArray <Derived>(3);
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            StructArray <int> a = new StructArray <int>(3);   //int배열로 size3

            a.Array[0] = 0;
            RefArray <string> b = new RefArray <string>(3);   //string배열로 size3

            b.Array[0] = "Hello";

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

            c.Array[0] = new Base();
            c.Array[1] = new Derived();
            c.Array[2] = createInstance <Derived>();
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            StructArray <int> a = new StructArray <int>(3);       //int 배열 3사이즈로 만듦

            a.Array[0] = 0;

            //StructArray<string> b = new StructArray<string>(3);//string은 참조형식

            //RefArray(skip)

            //BaseArray
            BaseArray <Base> b = new BaseArray <Base>(3);

            b.Array[0] = new Base();
            b.Array[1] = new Derived();
            b.Array[2] = CreatedInstance <Base>();
            //b.Array[2] = CreatedInstance<Derived>(); 이것도 가능

            BaseArray <Derived> d = new BaseArray <Derived>(3);
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            StructArray <int> a = new StructArray <int>(3);

            a.Array[0] = 0;
            //StructArray<string> b = new StructArray<string>(3); 값형식만 가능하기때문에 string 안됨

            //RefArray<>
            RefArray <string> b = new RefArray <string>(3);

            b.Array[0] = "hello";

            RefArray <StructArray <double> > e = new RefArray <StructArray <double> >(3); //string을 double로 변환

            e.Array[1] = new StructArray <double>(5);

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

            c.Array[0] = new Base();
            c.Array[1] = new Derived();
            c.Array[2] = CreatedInstance <Derived>();
            BaseArray <Derived> d = new BaseArray <Derived>(3);
        }
Esempio n. 9
0
        static void Main(string[] args)
        {
            StructArray <int> a = new StructArray <int>(3);

            for (int i = 0; i < a.Array.Length; i++)
            {
                a.Array[i] = 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);

            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();
            d.Array[1] = CreateInstance <Derived>();
            d.Array[2] = CreateInstance <Derived>();

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

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

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

            InterfaceArray <SthClass> f = new InterfaceArray <SthClass>(3);
            SthClass g = new SthClass();

            for (int i = 0; i < f.Array.Length; i++)
            {
                f.Array[i] = g.Method();
                Console.WriteLine(f.Array[i]);
            }
        }
Esempio n. 10
0
        static void Main(string[] args)
        {
            // 값 형식으로 제약
            StructArray <int> a = new StructArray <int>(3);

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

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

            // 참조형식으로 제약
            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>(200);

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

            // 기반 클래스로 제약
            BaseArray <Base> c = new BaseArray <Base>(3);

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

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

            // 기반 클래스로 제약
            BaseArray <Derived> d = new BaseArray <Derived>(3);

            d.Array[0] = new Derived(); //Derived가 기반 클래스가 되기 때문에 Base 할당 불가
            d.Array[1] = CreateInstance <Derived>();
            d.Array[2] = CreateInstance <Derived>();

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

            // U로부터 상속받은
            BaseArray <Derived> e = new BaseArray <Derived>(3);

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

            Console.WriteLine(e.Array.Length);

            //인터페이스 제약
            InterfaceArray <IWhatever> f = new InterfaceArray <IWhatever>(3);
        }
Esempio n. 11
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);
            for (int i = 0; i < b.Array[0].Array.Length; i++)
            {
                b.Array[0].Array[i] = b.Array[0].Array.Length + i;
            }

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

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

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

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

            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();
            d.Array[1] = CreateInstance <Derived>();
            d.Array[2] = CreateInstance <Derived>();

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

            e.CopyArray <Derived>(d.Array);
        }