csharp-3/lambda-expressions/lambda-demo-with-arrays.cs - Five equivalent functions - from anonymous method expressions to lambda expressions. | Lecture 6 - slide 10 : 20 Program 1 |
using System; using System.Collections.Generic; class Program{ public delegate double NumericFunction(double d); public static void Main(){ NumericFunction[] equivalentFunctions = new NumericFunction[]{ delegate (double d){return d*d*d;}, (double d) => {return d*d*d;}, (double d) => d*d*d, (d) => d*d*d, d => d*d*d }; foreach(NumericFunction nf in equivalentFunctions) Console.WriteLine("NumericFunction({0}) = {1}", 5, nf(5)); } }