public static TestList <T> operator +(TestList <T> list1, TestList <T> list2)
        {
            TestList <T> result = new TestList <T>();

            if (list1.Count != list2.Count)
            {
                throw new InvalidOperationException("Lists are different sizes!");
            }
            else
            {
                for (int i = 0; i < list1.Count; i++)
                {
                    result.Add((dynamic)list1[i] + (dynamic)list2[i]);
                }
            }

            return(result);
        }
Пример #2
0
        static void Test()
        {
            int[]    array  = { 3, 4, 2, 1, 5, 6, 7, 8, 12, 13, 4, 22, 15, 30, 76 };
            string[] sArray = { "a", "v", "c", "t", "g", "k", "l", "t", "w", "t", "c", "c" };

            int[] sortedArray = SelectionSort(array);;

            Person p1 = new Person()
            {
                Age = 10
            };
            Person p2 = new Person()
            {
                Age = 15
            };

            Console.WriteLine(AreEqual(2, 2));
            Console.WriteLine(p1.CompareTo(p2));

            TestList <int> firstIntList  = new TestList <int>();
            TestList <int> secondIntList = new TestList <int>();
            TestList <int> resultIntList = new TestList <int>();

            firstIntList.Add(1);
            firstIntList.Add(3);
            firstIntList.Add(5);

            firstIntList.Add(7);
            firstIntList.Add(3);
            firstIntList.Add(1);

            Console.WriteLine(firstIntList.Capacity);
            Console.WriteLine(firstIntList.Count);
            Console.WriteLine(firstIntList[0]);

            resultIntList = firstIntList + secondIntList;

            Console.WriteLine(resultIntList.ToString());
        }