Below is a sample code snippet that demonstrates how to use anonymous method to add two numbers in C#.
Example of Anonymous Method 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 Anonymous method in C# Func<int, int, int> Lambda = delegate(int a, int b) { return a + b; }; Console.WriteLine(Lambda(1, 2)); Console.ReadLine(); } } }
Leave a Reply