private string ProcessNumbersWithMsg(int a, int b, ProcessTwoNumbersDelegate processNumbersDelegate)
        {
            if (processNumbersDelegate == null)
            {
                return("Press Add/Subtract first!");
            }

            return("Weird msg! " + processNumbersDelegate(a, b));
        }
Exemplo n.º 2
0
        public void Run()
        {
            ProcessTwoNumbersDelegate Add = (x, y) => x + y;
            var additionResult            = Add(1, 2);

            Console.WriteLine($"Addition result is {additionResult}");

            ProcessTwoNumbersDelegate Multiply = (int x, int y) => { return(x * y); };
            var multiplicationResult           = Multiply(5, 7);

            Console.WriteLine($"Multiplicaiton result is {multiplicationResult}");

            var numbersRepository = new IntNumbersRepository(20);
            var divisibleBy3      = numbersRepository.Get(n => n % 3 == 0);

            Console.WriteLine("Numbers divisible by 3 are: " + string.Join(",", divisibleBy3));

            //OUTPUT
            // Addition result is 3
            // Multiplicaiton result is 35
            // Numbers divisible by 3 are: 0,3,6,9,12,15,18
        }