static void Main(string[] args) { Action<int> firstAction = DoWorkWithOneParameter; Action<int, int> secondAction = DoWorkWithTwoParameters; Action<int, int, int> thirdAction = DoWorkWithThreeParameters; firstAction(1); // Print 1 secondAction(1, 2); // Print 1-2 thirdAction(1, 2, 3); //Print 1-2-3 } public static void DoWorkWithOneParameter(int arg) { Console.WriteLine(arg); } public static void DoWorkWithTwoParameters(int arg1, int arg2) { Console.WriteLine(arg1 + "-" + arg2); } public static void DoWorkWithThreeParameters(int arg1, int arg2, int arg3) { Console.WriteLine(arg1 + "-" + arg2 + "-" + arg3); }
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