Example #1
0
        static void Main(string[] args)
        {
            Listard myListard = new Listard(10);

            myListard.Set(4710, 0);
            myListard.Set(4711, 1);

            // Eigene Klassen wie ein Array benutzen
            myListard[1] = 99;    // schreibender Zugriff
            int y = myListard[1]; // lesender Zugriff

            for (int i = 0; i < 100; i++)
            {
                myListard.Add(4712);
            }

            DateTime t1 = DateTime.Now;

            myListard.Add(new int[100000]);
            DateTime t2 = DateTime.Now;
            TimeSpan dt = t2 - t1;

            Listard myListard2 = new Listard();

            myListard2.Set(3710, 4);
            myListard2.Add(3711);
        }
        public void TestGetSet()
        {
            Listard <int> l = new Listard <int>();

            int[] block = new int[] { 4711, 4712, 4713 };
            l.Add(block);
            l[0] = 10 * l[0];
            l.Set(10 * l.Get(1), 1);
            if (l[0] != 47110)
            {
                throw new Exception();
            }
            if (l[1] != 47120)
            {
                throw new Exception();
            }
            if (l.Get(2) != 4713)
            {
                throw new Exception();
            }
            try {
                int test = l.Get(-1);
                throw new Exception();
            } catch (IndexOutOfRangeException) { /* expected error */ }
            try {
                int test = l.Get(l.Count);
                throw new Exception();
            } catch (IndexOutOfRangeException) { /* expected error */ }
        }
Example #3
0
        public void TestGetSet()
        {
            Listard <Position> l = new Listard <Position>();

            Position[] block = new Position[] { new Position("47|11"), new Position("47|12"), new Position("48|13") };
            l.Add(block);
            l[0].X = 10 * l[0].X;
            l.Set(new Position(l.Get(1).X, l.Get(1).Y * 10), 1);
            if (l[0].Text != "470|11")
            {
                throw new Exception();
            }
            if (l[1].Text != "47|120")
            {
                throw new Exception();
            }
            if (l.Get(2).Text != "48|13")
            {
                throw new Exception();
            }
            try {
                Position test = l.Get(-1);
                throw new Exception();
            } catch (IndexOutOfRangeException) { /* expected error */ }
            try {
                Position test = l.Get(l.Count);
                throw new Exception();
            } catch (IndexOutOfRangeException) { /* expected error */ }
        }