Accumulator function : Func « LINQ « C# / CSharp Tutorial






using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

    class MainClass
    {
        static void Main()
        {
            Func<int, Func<int, int>> accumulatorGenerator = (n => (i => n += i+8));
            var accumulator = accumulatorGenerator(1);
            Console.WriteLine(accumulator(1));
        }
    }








22.45.Func
22.45.1.Double recursive extension
22.45.2.Accumulator function
22.45.3.Add extension to Func
22.45.4.Build the necessary Func<> delegates using anonymous methods
22.45.5.Overloading By Delegate Return Type
22.45.6.Pass the delegates into the methods of Sequence
22.45.7.Lambda Expression for Func
22.45.8.Lambda Expression to retrieve string length