Below is a sample code snippet that demonstrates the function delegates or lambda expression in C# .

Example of Function Delegates in C#

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

namespace ACSample
{
    class Program
    {
        static void Main(string[] args)
        {
            // Example of Funcition Delegate / Lambda Expression to add 2 numbers
            Func<int, int, int> Lambda = (a, b) => (a + b);
            Console.WriteLine(Lambda(1, 2));
            Console.ReadLine();
        }

    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Liked this content?. Please spread the word :)

  • RSS
  • Twitter
    Visit Us
    Follow Me