public void Test()
        {
            var delegate1 = new NoParametersNoReturnDelegate(Func1);

            delegate1();

            ParametersNoReturnDelegate delegate2 = null;

            delegate2 = Func2;
            //if (delegate2 != null)
            //    delegate2("param");
            delegate2?.Invoke("param");

            Delegate3 += Func3;

            for (var i = 0; i < 3; i++)
            {
                for (int ii = 0; ii < 5; ii++)
                {
                    if (Delegate3(i, ii))
                    {
                        Console.WriteLine($"{i} == {ii}");
                    }
                    else
                    {
                        Console.WriteLine($"{i} != {ii}");
                    }
                }
            }
        }
Пример #2
0
        public void Test()
        {
            var delegate1 = new NoParametersNoReturnTypeDelegate(Fun1);

            //delegate1();
            //if (delegate1 != null)
            //    delegate1.Invoke();
            delegate1?.Invoke();

            ParametersNoReturnTypeDelegate delegate2 = null;

            delegate2 += Fun2;
            delegate2?.Invoke("some string");

            Delegate3 += Fun3;

            for (var i = 0; i < 3; i++)
            {
                if (Delegate3(1, i))
                {
                    Console.WriteLine("==");
                }
            }
        }