using System; namespace ConsoleApp2 { class Program { delegate double Function(double x); static void Main(string[] args) { double[] a = { 0.0, 0.5, 1.0 }; //double[] squares = Apply(a, Square); //double[] sines = Apply(a, Math.Sin); double[] squares = Apply(a, new Function(Square)); double[] sines = Apply(a, new Function(Math.Sin)); Multiplier m = new Multiplier(2.0); double[] doubles = Apply(a, m.Multiply); } static double Square(double x) { return x * x; } static double[] Apply(double[] a, Function f) { double[] result = new double[a.Length]; for (int i = 0; i < a.Length; i++) { result[i] = f(a[i]); } return result; } } class Multiplier { double factor; public Multiplier(double factor) { this.factor = factor; } public double Multiply(double x) { return x * factor; } } }