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 #2
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);
        }
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);
        }
Beispiel #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]);
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            //StructArray<string> a = new StructArray<string>(3);   //값형식이 아닌 문자열일경우 오류발생
            RefArray <string> b = new RefArray <string>(4);           //문자열은 참조형식이므로 사용가능

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

            c.Array[0] = new Base();
            c.Array[1] = new Derived(); //베이스를 상속받았기때문에 사용가능
            c.Array[2] = CreateInstamce <Base>();
            c.Array[3] = CreateInstamce <Derived>();

            BaseArray <Derived> d = new BaseArray <Derived>(3);
        }
Beispiel #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>();
        }
Beispiel #7
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);
        }
Beispiel #8
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]);
            }
        }
Beispiel #9
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);
        }
Beispiel #10
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);
        }