csharp-3/lambda-expressions/lambda-demo.cs - Five equivalent functions - from anonymous method expressions to lambda expressions. | Lecture 5 - slide 36 : 45 Program 1 |
using System; using System.Collections.Generic; class Program{ public delegate double NumericFunction(double d); public static void Main(){ List<NumericFunction> equivalentFunctions = new List<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)); } }