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);
}
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter