Lambda Expression to retrieve string length : Func « LINQ « C# / CSharp Tutorial






using System;
using System.ComponentModel;

    class MainClass
    {
        static void Main()
        {
            Func<string, int> returnLength = (string text) => { return text.Length; };

            Console.WriteLine(returnLength("Hello"));
        }
    }








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