lambda expressions

Lambda expressions allow us to reduce the code, thereby reducing the complexity of the code. Here is an example:

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

namespace ConsoleApplication10
    class Program
        static void Main(string[] args)
            Func<string, string> lambda = param =>
                return param + " XYZ ";

            Func<string, string> oneParam = s =>
String.Format("change uppercase {0}", s.ToUpper());


            Console.WriteLine(lambda("This is "));

In above example, the left side of lambda operator => is the parameter passed to function. The right side of lambda operator defines the implementation of the method.

Add a Comment

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