What you want to see on DotNetFunda.com ?
Go to DotNetFunda.com
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 20084 |  Welcome, Guest!   Register  Login
Home > Articles > LINQ > Lambda Expressions in C#

Lambda Expressions in C#

Article posted by Muhilan on 11/30/2009 | Views: 6019 | Category: LINQ | Level: Beginner red flag


This Article demonstrate the basic functionality of Lambda Expression in C#(Console Application).

About Lambda Expression
  • A lambda expression is an function that contain many expressions and statements.
  • Lambda expression used to create delegates or expression tree types.
  • All lambda expressions use the lambda operator =>, which is read as "goes to".
  • The left side of the lambda operator specifies the input parameters.
  • The right side holds the expression or statement block

 Lambda Expression used to Create two ways.

  1.     Delegates
  2.     Expression Tree Types.
  Delegates with Examples

  Single Parameter

       The lambda expression Y => Y * Y is read "Y goes to Y times Y."

 delegate int ADD(int i);
 static void Main(string[] args)
{
    ADD Delgts = i => i * i;
    int K = Delgts(5);
Console.WriteLine(K);
}


Output : 25
  Multiple Parameter
   delegate int ADD(int i,int y );
       static void Main(string[] args)
        {
            ADD Delgts = (i, Z) => i * Z;
            int K = Delgts(10, 20);
            Console.Write(K);
    }

                   Output :200

Lambdas with Standard Query Operators standard query operator, the Count method

int[] Numb = { 15, 14, 11, 13, 19,18,16, 17, 12, 10 };

            int TotalOddno = Numb.Count(n => n % 2 == 1);

                    Console.Write(TotalOddno);

                         Output : 5
Conclusion
This article shows basic about LAMBDA Expressions.

If you like this article, subscribe to our RSS Feed. You can also subscribe via email to our Interview Questions, Codes and Forums section.

Page copy protected against web site content infringement by Copyscape
Found interesting? Add this to:



Please Sign In to vote for this post.

About Muhil an

Experience:3 year(s)
Home page:
Member since:Monday, November 30, 2009
Level:Starter
Status: [Member]
Biography:working as an IT System Analyst,tmuhilan at gmail com
>> Write Response - Respond to this post and get points
Related Posts

In this article, I shall show how to use frequently used LINQ extension methods. In order to work with LINQ we need to use from System.Linq namespace.

The article demonstrates the different core concepts of LINQ to XML with an easy console application that will create an XML document dynamically.

In this article , we will look into as how we can implement Row_Number() function of Sql Server in LINQ using C# as the language of choice.

This is the article which will explain how to use linq

Entity Data Model (EDM) is bridge between application and database. LINQ(Language Integated Query) to entity which performs CRUD operations against the Entity Data Model(EDM)

More ...
About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/23/2013 3:24:12 AM