Monday, June 23, 2025 15:35

Posts Tagged ‘delegate chains’

Closures

Sunday, February 2nd, 2020

Let’s consider the following Action:

using System;

namespace HelloWorld
{

    public class Program
    {
        public static void Main()
        {
            int i = 0;

            Action a = () => i++;

            a();
            a();
            a();

            Console.WriteLine(i);

            Console.Read();
        }
    }
}

From the lesson Func and Action, you remember that an Action is just a delegate that returns void and takes between 0 and 16 parameters of any type.… Read more