コード例 #1
0
        public override void ExerciseRun()
        {
            List <int> list = new List <int> {
                1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
            };

            Exercise22.ShowList(list);
            bool delegateMethodIsSet = SetDelegateMethod();

            if (delegateMethodIsSet)
            {
                List <int> processedList = On_All(list, deleg);
                if (deleg == ReturnPowerOfTwo)
                {
                    Console.WriteLine("The first 20 perfect squares are: ");
                }
                if (deleg == ReturnPowerofThree)
                {
                    Console.WriteLine("The first 20 perfect cubes are: ");
                }
                Exercise22.ShowList(processedList);

                var result1 = On_AllExpression(list, number => number * number);
                var result2 = On_AllFunc(list, number => number * number);
                var result3 = On_All(list, number => number * number);
                var result4 = list.Select(number => number * number).ToList();
            }
        }
コード例 #2
0
        // <task_description>
        /// 7.	Write three functions that compute the sum of the numbers in a list:
        /// using a for-loop, a while-loop and recursion.
        /// </task_description>
        public override void ExerciseRun()
        {
            List <int> list = new List <int> {
                1, 2, 3, 4, 5
            };

            Exercise22.ShowList(list);

            Console.WriteLine($"\nThe sum of all elements un list, counted with CountSumWithRecursion metod is {CountSumWithRecursion(list)}");
            Console.WriteLine($"\nThe sum of all elements un list, counted with CountSumWithForCycle metod is {CountSumWithForCycle(list)}");
            Console.WriteLine($"\nThe sum of all elements un list, counted with CountSumWithWhileCycle metod is {CountSumWithWhileCycle(list)}");
        }
コード例 #3
0
ファイル: Exercise210.cs プロジェクト: vacho87/Exercises
        public override void ExerciseRun()
        {
            List <object> list1 = new List <object> {
                1, 2, 3, 4, 5
            };
            List <object> list2 = new List <object> {
                "a", "b", "c", "d", "e"
            };
            var mixedList = MixTwoLists(list1, list2);

            Exercise22.ShowList(list1, "\"list1\"");
            Exercise22.ShowList(list2, "\"list2\"");
            Exercise22.ShowList(mixedList, "\"mixedList\"");
        }
コード例 #4
0
ファイル: Exercise24.cs プロジェクト: vacho87/Exercises
        public override void ExerciseRun()
        {
            List <int> sourceList = new List <int> {
                1, 2, 3, 4, 5, 6, 7, 8, 9
            };

            Console.WriteLine("The source list looks like that:\n");
            Exercise22.ShowList(sourceList);

            List <int> resultList = ReturnElementsOnOddPosition(sourceList);

            Console.WriteLine("The result list, that contains members of source list that hold on odd positions:\n");
            Exercise22.ShowList(resultList);
        }
コード例 #5
0
ファイル: Exercise29.cs プロジェクト: vacho87/Exercises
        public override void ExerciseRun()
        {
            List <object> list1 = new List <object> {
                1, 2, 3, 4, 5
            };

            Exercise22.ShowList(list1, "\"list1\"");

            List <object> list2 = new List <object> {
                'a', 'b', 'c', 'd', 'e'
            };

            Exercise22.ShowList(list2, "\"list2\"");

            List <object> concatenatedList = ConcatenateTwoLists(list1, list2);

            Exercise22.ShowList(concatenatedList, "\"concatenatedlist\"");
        }
コード例 #6
0
ファイル: Exercise23.cs プロジェクト: vacho87/Exercises
        public override void ExerciseRun()
        {
            List <int> list = new List <int> {
                1, 2, 3, 4, 5, 6, 7, 8
            };

            Exercise22.ShowList(list);
            Console.WriteLine();

            if (ContainsElement(list, 3))
            {
                Console.WriteLine("Element \"3\" occures in list. \n");
            }
            else
            {
                Console.WriteLine("Element \"3\" is absent in list\n");
            }


            if (ContainsElement(list, 11))
            {
                Console.WriteLine("Element \"11\" occures in list.\n");
            }
            else
            {
                Console.WriteLine("Element \"11\" is not occures in list\n");
            }

            // native method applied
            if (list.Contains(5))
            {
                Console.WriteLine("Native method \" list.Contains\" defines that element \"5\" occures in list\n");
            }
            else
            {
                Console.WriteLine("Native method \" list.Contains\" defined that element \"5\" is not occures in list\n");
            }
        }