// C# Extension Method
// Doc: https://csharp-extension.com/en/method/1002639/array-foreach
// @nuget: Z.ExtensionMethods
using System;
public class Program
{
public static void Main()
int[] intArray = new int[] { 2, 3, 4 };
Action<int> action = new Action<int>(ShowSquares);
// C# Extension Method: Array - ForEach
intArray.ForEach(action);
}
private static void ShowSquares(int val)
Console.WriteLine("{0:d}^2 = {1:d}", val, val * val);