WHAT IS THE SYNTAX FOR LAMBDA EXPRESSIONS IN VB.NET?

Manoj Bhatt

Total Post:154

Points:1086
Posted by  Manoj Bhatt
C#  .NET 
C#
 500  View(s)
Ratings:
Rate this:
Sorry for dumb question, but I can not proper understanding of the lambda expression.please give me a appropriate answer?


  1. Anupam Mishra

    Post:135

    Points:949
    Re: What is the syntax for Lambda Expressions in VB.NET?

    In C#, Lambda expressions reduce the amount of work needed when iterating through data.  All enumerable data is queryable through LINQ with use of a SQL-like query (what I mean by that is the query looks like SQL, but is a different flavor). LINQ has an in-built mechanism to loop through enumerable data and use certain conditions setup in the where clauses to filter the data.  LINQ queries are quite effective in what they do.

    Lambda expressions work in a similar way. Some of the existing extension methods feature built-in lambda expressions to perform certain actions and to make it easier to perform repetitive work.  We shall see this soon.  Lambda expressions do not require extension methods to work, but this is the most common usage currently.

    For example, 

    static void Main()

        {

         List<int> elements = new List<int>() { 100,200,300,400 };

          // ... Find index of first even element.

         int Index = elements.FindIndex(x => x % 2 = 0); //Here we using lambda expression

         Console.WriteLine(Index);

        }


    As you can see, it is really easy to use lambda expressions and embeds them in your applications.  They really add a lot of functionality to an application. Lambda expressions are commonly exposed through static methods, but they can be used in other situations as well. Extension methods are not required, though this is the most common usage in the .NET Framework as of now.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!