Pass a Function as a Parameter in C# using Action delegate | Delft Stack

PHOTO EMBED

Sun Sep 19 2021 18:26:26 GMT+0000 (UTC)

Saved by @dejohnny #c

using System;

namespace pass_function_as_parameter
{
    class Program
    {
        static void functionToPass2(int x)
        {
            int increment = x + 10;
            Console.WriteLine("increment = {0}",increment);
        }
        static void function2(Action<int> functionToPass2)
        {
            functionToPass2(22);
        }
        static void Main(string[] args)
        {
            function2(functionToPass2);
        }
    }
}
content_copyCOPY

https://www.delftstack.com/howto/csharp/pass-function-as-parameter-inside-another-function-in-csharp/