public int Add(int x, int y)
        {
            var sum = x + y;

            if (sum % 5 == 0)
            {
                OnMultipleOfFiveReached?.Invoke(this, new MultipleOfFiveEventArgs(sum));
            }
            return(sum);
        }
Beispiel #2
0
        public int Add(int x, int y)

        {
            int iSum = x + y;

            if ((iSum % 5 == 0) && (OnMultipleOfFiveReached != null))

            {
                OnMultipleOfFiveReached.Invoke();
            }

            return(iSum);
        }
Beispiel #3
0
        public event Action <int> OnMultipleOfFiveReached; //does it work without 'event' keyword? why do we use it?

        public int Add(int x, int y)
        {
            var sum = x + y;

            if (sum % 5 == 0)
            {
                OnMultipleOfFiveReached?.Invoke(sum);
            }

            /*
             * obj?.method();
             *
             * is same as:
             *
             * if (obj != null)
             * {
             *  obj.method();
             * }
             */
            return(sum);
        }