exploring lambda expression in c# - codeproject

Upload: davidesesti

Post on 17-Oct-2015

30 views

Category:

Documents


0 download

DESCRIPTION

Exploring Lambda Expression in C# - CodeProject

TRANSCRIPT

  • 5/27/2018 Exploring Lambda Expression in C# - CodeProject

    1/5

    16/4/2014 Exploring Lambda Expression in C# - CodeProject

    http://www.codeproject.com/Articles/24255/Exploring-Lambda-Expression-in-C 1/8

    10,544,055 members (65,352 onli ne) Sign in

    home quick answers discussions features community help Search for articles, questions, tips

    Articles Languages C# Delegates and Events

    Article

    Browse Code

    Bugs / Suggestions

    Stats

    Revisions

    Alternatives

    Comments (18)

    Share

    About Article

    This article covers thingsfrom syntax to constraintsand implementation detailsfor lambda expression in C#

    Type Article

    Licence CPOL

    First Posted 10 Mar 2008

    Views 281,581

    Bookmarked 170 times

    C#3.0 C# .NET DevIntermediate

    Top News

    C# 6: First reactions

    Get the Insider Newsfree eachmorning.

    Related Videos

    Next

    Rate this:

    Exploring Lambda Expression in C#By Zeeshan Jafar Hirani, 12 Mar 2008

    Introduction

    Lambda expression is an inline delegate introduced with C # 3.0 language. Its a concise way to represent an

    anonymous method. It provides a syntax to create and invoke functions. Although Lambda expressions are simpler to

    use than anonymous methods, they do slightly differ on how they are implemented. Both anonymous methods and

    Lambda expressions allow you define the method implementation inline, however, an anonymous method explicitly

    requires you to define the parameter types and the returntype for a method. Lambda expression uses the typeinference feature of C# 3.0 which allows the compiler to infer thetype of the variable based on the context.

    Lambda expression can be broken down into parameters followed by execution code. e.g.:

    Collapse | Copy Code

    Parameter => executioncode.

    The lefthand side represents zero or more parameters followed by the lambda symbol =>which is used to separate

    the declaration of a parameter from the implementation of the method. Lambda expression is then followed by the

    statement body.

    Lambda expressionallowsus to pass functions as arguments to a method call. I will start with a simple example of

    lambda expression which returns even numbers from a list of integers.

    Collapse | Copy Code

    //simple example of lambda expression.

    publicstaticvoidSimpleLambdExpression() { List numbers = newList{1,2,3,4,5,6,7};

    varevens = numbers.FindAll(n => n % 2== 0); varevens2 = numbers.FindAll((intn) => { returnn % 2== 0; }); ObjectDumper.Write(evens); ObjectDumper.Write(evens2);

    }

    Looking at the first lambda expression assigned to the evensvariable, you will notice few things that are different from

    anonymous methods. First, we are not using delegatekeyword anywhere in our code. Second, we are not defining

    the parameter and return types because the compiler infers the type based on context. The types in the expression are

    determined by the delegatedefinition. So in this case return type specified by the FindAllmethod takes a

    delegatewhich takes an intparameter and returns boolean. Lambda expression without braces and return type,

    provides the most concise way to represent anonymous methods. If the number of parameters is one then you can

    omit the parentheses surrounding the parameter as demonstrated in the first lambda expression. Although lambda

    expression does not require explicit parameters, you have the option to define the parameters, braces and return type

    as shown in the second lambda expression assigned to the even2variable. Notice that we are using the explicitparameter of intand also use the return type as we usually specify in a method. The return statement would not

    work if you do not enclose the execution code with parentheses considering that you are fully qualifying everything

    that attributes a method.

    Another place where parentheses are required in lambda expressions is when you want to use a parameter in multiple

    blocks of code inside the lambda expression such as follows:

    Collapse | Copy Code

    delegatevoidWriteMultipleStatements(inti);

    publicstaticvoidMultipleStatementsInLamdas() { WriteMultipleStatements write = i => {

    Console.WriteLine("Number "+ i.ToString()); Console.WriteLine("Number "+ i.ToString()); }; write(1); }

    4.57 (60 votes)

    articles

    http://www.codeproject.com/Articles/24255/Exploring-Lambda-Expression-in-C?display=Printhttp://www.codeproject.com/script/common/TellFriend.aspx?obtid=2&obid=24255http://www.codeproject.com/Tags/Intermediatehttp://www.codeproject.com/script/Membership/View.aspx?mid=4858678http://www.codeproject.com/script/Answers/List.aspx?tab=activehttp://www.codeproject.com/script/Forums/List.aspxhttp://www.codeproject.com/Feature/http://www.codeproject.com/Lounge.aspxhttp://www.codeproject.com/KB/FAQs/http://www.codeproject.com/http://www.codeproject.com/http://www.codeproject.com/script/Articles/Latest.aspxhttp://www.codeproject.com/script/Membership/View.aspx?mid=4858678http://www.codeproject.com/script/Articles/PrevNextLookup.aspx?aid=24255&at=1&secId=93http://www.codeproject.com/Feature/Insider/http://msmvps.com/blogs/jon_skeet/archive/2014/04/04/c-6-first-reactions.aspxhttp://www.codeproject.com/script/common/TellFriend.aspx?obtid=2&obid=24255http://www.codeproject.com/Articles/24255/Exploring-Lambda-Expression-in-C?display=Printhttp://www.codeproject.com/Tags/Intermediatehttp://www.codeproject.com/Tags/Devhttp://www.codeproject.com/Tags/.NEThttp://www.codeproject.com/Tags/C--hash--http://www.codeproject.com/Tags/C--hash--3.0http://www.codeproject.com/info/cpol10.aspxhttp://www.codeproject.com/script/Articles/Types.aspx?#Articlehttp://www.codeproject.com/Articles/24255/WebControls/#_commentshttp://www.codeproject.com/script/Articles/ListAlternatives.aspx?aid=24255http://www.codeproject.com/script/Articles/ListVersions.aspx?aid=24255http://www.codeproject.com/script/Articles/Statistics.aspx?aid=24255http://www.codeproject.com/script/Articles/ViewTasks.aspx?aid=24255http://www.codeproject.com/script/Articles/ViewDownloads.aspx?aid=24255http://www.codeproject.com/KB/cs/#Delegates+and+Eventshttp://www.codeproject.com/KB/cs/http://www.codeproject.com/Chapters/5/Languages.aspxhttp://www.codeproject.com/script/Content/SiteMap.aspxhttp://www.codeproject.com/KB/FAQs/http://www.codeproject.com/Lounge.aspxhttp://www.codeproject.com/Feature/http://www.codeproject.com/script/Forums/List.aspxhttp://www.codeproject.com/script/Answers/List.aspx?tab=activehttp://www.codeproject.com/https://www.codeproject.com/script/Membership/LogOn.aspx?rp=%2fArticles%2f24255%2fExploring-Lambda-Expression-in-Chttp://workspaces.codeproject.com/http://-/?-http://www.codeproject.com/http://-/?-
  • 5/27/2018 Exploring Lambda Expression in C# - CodeProject

    2/5

    16/4/2014 Exploring Lambda Expression in C# - CodeProject

    http://www.codeproject.com/Articles/24255/Exploring-Lambda-Expression-in-C 2/8

    Related Articles

    Lambda Expressions

    Explicating the new C++standard (C++0x), and itsimplementation in VC10

    Way to Lambda

    Lambda Expressions and

    Expression Trees: AnIntroduction

    C++11 Lambda StorageWithout libc++

    Understand Lambda Expressionsin 3 minutes

    Strong: Reflection withoutmagic strings

    using of lam bda expression andremoving foreach/for loop

    Using lambdas - C++ vs. C# vs.C++/CX vs. C++/CLI

    Expression Tree

    Lambda Simplified

    Sexy C#

    C# Delegates, AnonymousMethods, and LambdaExpressions O My !

    Functional programming in C#

    Concepts behind the C# 3.0language

    Factorial Simplified usinglambda

    CLinq - L INQ support for the

    C++/CLI language

    Generate AST for the DLR

    Replacing foreach loop withLINQ

    LINQ to Life

    Related Research

    Essential Keys to MobileUsability

    Protecting Your Business Data:Five Dos and Donts

    In the above code sample, we have enclosed our code in curly brackets so that we can use the parameter in both theexpressions. If there were no curly brackets, the compiler wouldn't be able to recognize the variable i.

    You can use lambda expressions where a delegate may not have any parameter. In that case, you have to supply a pair

    of empty parentheses to signify a method with no parameter. Here is a simple example which illustrates a lambda with

    no parameter.

    Collapse | Copy Code

    delegatevoidLambdasNoParams();

    publicstaticvoidLambdasWithNoParameter() { LambdasNoParams noparams = () => Console.WriteLine("hello"); noparams();

    }

    C# 3.0 defines the number of generic delegates that you can assign to your lambda expression instead of varkeyword

    which infers the type. Let's take a look at an example of using a few of those generic delegates:

    Collapse | Copy Code

    publicstaticvoidGenericDelegates() {

    List numbers = newList { 1, 2, 3, 4, 5, 6, 7}; Func where = n => n < 6; Func select = n => n; Func orderby = n => n % 2== 0? "even": "odd";

    varnums = numbers.Where(where).OrderBy(orderby).Select(select); ObjectDumper.Write(nums); }

    In the above example, we are using three different extension methods: where, orderbyand select. The where

    extension method takes a generic delegatewith intparameter and a return type of boolean to identity if a certain

    element be included in the output sequence. The selectextension method takes an integer parameter and returns an

    integer, but it could return anything that you want the result to be transformed into before being sent to the

    output sequence. In the orderbyextension method, we are taking the integer parameter and using it to identify if it is

    even or odd. Based on that, we sort the results. It would have been extremely cumbersome if we had to define three

    different delegates for each of these lambda expressions. With the introduction of generic delegates in C# 3.0, it is

    fairly non trivial to assign our lambda expressions to generic delegates and pass those delegates to the extension

    methods. Generic delegates come in pretty handy and help you avoid writing common delegates which was

    common in .NET 1.1 and .NET 2.0 (since there were no generic delegates that came out of the box). Generic

    delegates allow you to define up to 4 parameters and 1 return type so you can have a delegatethat may look

    something like this:

    Collapse | Copy Code

    Func test;

    If your method or delegatedoes not meet the criteria then you have to manually declare a delegatethat takes

    those parameters. Generic delegates usually cover majority of scenarios but in cases where it does not meet your

    needs, feel free to write a custom delegate.

    There are cases where type inference may not return the data type that you really want the lambda expression to

    return. In those cases, we can explicitly specify the parameter type on the lambda expression. For example:

    Collapse | Copy Code

    Func expr = (x) => x / 2;

    The above expression returns a compiler error because by dividing a double, the inferred type is actually going to be

    double. However, you are assigning the lambda expression to a delegatethat has a return type of int. If intis

    what you really want to return from the method, then you are better off casting the expression body to intto

    indicate your intent as shown below:

    Collapse | Copy Code

    Func expr = (x) => (int)x / 2;

    http://www.codeproject.com/ResearchLibrary/40/Protecting-Your-Business-Data-Five-Do-s-and-Don-tshttp://www.codeproject.com/ResearchLibrary/46/Essential-Keys-to-Mobile-Usabilityhttp://www.codeproject.com/Articles/24136/LINQ-to-Lifehttp://www.codeproject.com/Tips/272471/Replacing-foreach-loop-with-LINQhttp://www.codeproject.com/Articles/28299/Generate-AST-for-the-DLRhttp://www.codeproject.com/Articles/17844/CLinq-LINQ-support-for-the-C-CLI-languagehttp://www.codeproject.com/Tips/190028/Factorial-Simplified-using-lambdahttp://www.codeproject.com/Articles/15976/Concepts-behind-the-C-languagehttp://www.codeproject.com/Articles/375166/Functional-programming-in-Csharphttp://www.codeproject.com/Articles/47887/C-Delegates-Anonymous-Methods-and-Lambda-Expressiohttp://www.codeproject.com/Articles/696879/Sexy-Csharphttp://www.codeproject.com/Tips/119001/Lambda-Simplifiedhttp://www.codeproject.com/Tips/438804/Expression-Treehttp://www.codeproject.com/Articles/277612/Using-lambdas-Cplusplus-vs-Csharp-vs-Cplusplus-CXhttp://www.codeproject.com/Tips/193518/using-of-lambda-expression-and-removing-foreach-fohttp://www.codeproject.com/Articles/28514/Strong-Reflection-without-magic-stringshttp://www.codeproject.com/Tips/298963/Understand-Lambda-Expressions-in-minuteshttp://www.codeproject.com/Articles/313312/Cplusplus-Lambda-Storage-Without-libcplusplushttp://www.codeproject.com/Articles/17575/Lambda-Expressions-and-Expression-Trees-An-Introduhttp://www.codeproject.com/Articles/507985/Way-to-Lambdahttp://www.codeproject.com/Articles/71540/Explicating-the-new-C-standard-C-x-and-its-implemhttp://www.codeproject.com/Articles/667180/Lambda-Expressionshttp://codeproject.tv/video/5021062/javascript_regular_expressions_part_2http://codeproject.tv/video/7624481/c_tutorial_-_26_-_delegates
  • 5/27/2018 Exploring Lambda Expression in C# - CodeProject

    3/5

    16/4/2014 Exploring Lambda Expression in C# - CodeProject

    http://www.codeproject.com/Articles/24255/Exploring-Lambda-Expression-in-C 3/8

    Learn Agile: Ten Tips forLaunching and Testing High

    Quality Apps for the AmericanMarket

    Protecting Android

    Applications with Secure CodeSigning Certificates

    Lambda expressions are basically of two types. One is considered a simple expression where everything is inferred and

    consists of an expression only. The second type of lambda expression is statement blocks which are composed of

    braces and return type. Let's write a lambda expression in both forms to see the difference:

    Collapse | Copy Code

    //example showing two types of lambda expressions

    publicstaticvoidExplicitParametersInLambdaExpression(){

    Func square = x => x * x; Func square1 = (x) => { returnx * x; };

    Expression squareexpr = x => x * x;

    Expression square2 = (intx) => { returnx * x; };//does not compile.}

    Let's go ahead and dissect each lambda expression one at a time. The first lambda expression is considered a simple

    expression which does not have a statement body because there is no return statement and braces whereas the

    second lambda statement includes a statement body because it has a return statement and braces. Although both get

    compiled to a delegate, the benefit of lambda expressions without a statement body is that it can be converted to an

    expression tree which a certain provider can use to generate its own implementation. This is much like LINQ to SQL will

    convert the expression tree to its domain specific language called SQL, and send it to the database. The third lambda

    expression is really where lambda expression shies from an anonymous method. The beauty of this statement is the

    fact that you can easily convert to an expression whereas anonymous methods can only be converted to delegates.

    What is also great is that an expression can be converted back to a delegateby compiling the expression to

    delegatewith the following syntax:

    Collapse | Copy Code

    Func sq = squareexpr.Compile();

    The last lambda expression raises an exception because the compiler cannot convert a lambda expression that contains

    a statement body, as you can observe from the fact that it is surrounded by braces and a return statement.

    Although you can use lambda expressions to generate expression trees, there is nothing preventing you from directly

    creating your own expression tree. Lets walk through an example of creating an expression tree for a lambda

    expression square = x =>x * x.

    Collapse | Copy Code

    //example creates expression tree of x *x

    publicstaticvoidCreatingExpressionTree() { ParameterExpression parameter1 = Expression.Parameter(typeof(int), "x");

    BinaryExpression multiply = Expression.Multiply(parameter1, parameter1); Expression square = Expression.Lambda( multiply, parameter1); Func lambda = square.Compile(); Console.WriteLine(lambda(5));

    }

    You first start off with a parameter expression of type int.

    Collapse | Copy Code

    ParameterExpression parameter1 = Expression.Parameter(typeof(int), "x");

    The next step is to build the body of lambda expressions which happens to be a binary expression. The body consists of

    a multiply operator to the same parameter expression.

    Collapse | Copy Code

    BinaryExpression multiply = Expression.Multiply(parameter1, parameter1);

    The final step is to build the lambda expression which combines the body with the parameter as follows:

    Collapse | Copy Code

    Expression square = Expression.Lambda(multiply,

    parameter1);

    The last step converts the expression to delegateand executes the delegateas follows:

    Collapse | Copy Code

    Func lambda = square.Compile();

    Console.WriteLine(lambda(5));

    Creating An Expression from Another Expression

    You can take an expression tree and modify it to create another expression from it. In the following example, we will

    start off with a lambda expression of x *xand then modify this expression to add 2to it. Lets have a look at an

    example:

    Collapse | Copy CodepublicstaticvoidCreatingAnExpressionFromAnotherExpression() { Expression square = x => x * x; BinaryExpression squareplus2 = Expression.Add(square.Body,

    Expression.Constant(2)); Expression expr = Expression.Lambda(squareplus2, square.Parameters);

    Func compile = expr.Compile();

    http://www.codeproject.com/ResearchLibrary/31/Protecting-Android-Applications-with-Secure-Code-Shttp://www.codeproject.com/ResearchLibrary/20/Learn-Agile-Ten-Tips-for-Launching-and-Testing-Hig
  • 5/27/2018 Exploring Lambda Expression in C# - CodeProject

    4/5

    16/4/2014 Exploring Lambda Expression in C# - CodeProject

    http://www.codeproject.com/Articles/24255/Exploring-Lambda-Expression-in-C 4/8

    Console.WriteLine(compile(10)); }

    We start off with a lambda expression which returns a square:

    Collapse | Copy Code

    Expression square = x => x * x;

    Next we generate the body of the new lambda expression by using the body of the first lambda expression and adding

    a constant of 2to it and assigning it to the binary expression:

    Collapse | Copy Code

    BinaryExpression squareplus2 = Expression.Add(square.Body, Expression.Constant(2));

    In the last step, we generate the new lambda expression by combining the body with the parameters from the first

    lambda expression. The important point which I discovered in the statement below is that, a parameter's reference

    needs to be exactly the same from the first lambda expression which is square.Parameters. You cannot create a new

    instance of parameters collection which results in a runtime error.

    Collapse | Copy Code

    Expression expr = Expression.Lambda(squareplus2, square.Parameters);

    Closures and Lambda Expressions

    Closure is a concept that comes from functional programming. It essentially captures or uses the variable which is

    outside the scope of the lambda expression. What it essentially means is you can use variables inside the lambda

    expression that are declared outside the scope of the lambda expression you are able to use and capture thevariable that is outside the scope of the lambda expression. This has its advantages but could lead to issues as well

    since the outside context has the ability to change the variable value. Lets drill through an example of lambda

    expression in the context of closure.

    Collapse | Copy Code

    publicstaticvoidLambdaWithClosure() { intmulitplyby = 2; Func operation = x => x * mulitplyby;

    Console.WriteLine(operation(2)); }

    In the above example, we are using the mulitplybyvariable inside the lambda expression although it is declared

    outside the scope of the expression. This concept is called variable capture. In the background, C# compiler takes all

    those captured variables and puts them in a generated class. When you are using lambda expressions with outside

    variables, they are not picked up by the garbage collector, and are forced to hang around until they are used by the

    lambda expressions and the expression goes out of scope.

    There are certain restrictions when you are using a lambda expression with a parameter with refand outkeyword.

    When your variable is passed with refor outkeyword, you must explicitly specify the parameter type because the

    compiler cannot infer the type of the variable. As shown in the example below:

    Collapse | Copy Code

    delegatevoidOutParameter(outinti); delegatevoidRefParameter(refinti); publicstaticvoidGotchasWithLambdas()

    { //example with out parameter int i;

    OutParameter something = (outintx) => x = 5; something(outi);

    Console.WriteLine(i);

    //example with ref parameter.

    inta = 2;

    RefParameter test = (refintx) => x++;

    test(refa); Console.WriteLine(a); }

    Notice in the above code, I am explicitly specifying the parameter type of intin both cases, refand out. If I omit the

    parameter type, the compiler will raise an error.

    Another restriction that I have come across using lambdas is you cannot use the paramskeyword in the parameter

    type for a lambda expression regardless of whether or not you explicitly specify the type of the parameter. The

    following code does not compile because the parameter definition is attributed with params keyword:

    Collapse | Copy Code

    delegatevoidParmsParameter(paramsint[] ints); publicstaticvoidLambdaWithParam() { ParmsParameter par = (paramsint[] ints) => {

    foreach(inti inints) { Console.WriteLine(i); }

    }; }

    Summary

  • 5/27/2018 Exploring Lambda Expression in C# - CodeProject

    5/5

    16/4/2014 Exploring Lambda Expression in C# - CodeProject

    http://www.codeproject.com/Articles/24255/Exploring-Lambda-Expression-in-C 5/8

    Zeeshan Jafar HiraniSoftware Developer (Senior) Tarrant

    Regional Water District

    United States

    General Certificate of Education obtained in Math, Physics, Chemistry, Principle of Accounts &

    Statistics in the year 1998-99 from the University of Cambridge, London, England.

    Earned a degree in Business Administration in Information System with a GPA of 3.6 on 4.0 scales

    from Univ. of Texas At Arlington in Honors in the year 2005.

    Certified MCAD,MCSD,MCPD ,OCP (Oracle Certified Professional),MCDBA.

    I have been working as an Asp.net C# developer for last 3 years.

    Zeeshan Hirani

    Senior Asp.net Developer

    Tarrant Regional Water District

    [email protected]

    http://www.trwd.com

    Search this forum Go

    In this article I introduced the syntax of a lambda expression how it replaces anonymous methods. We also talked

    about how lambda expressions differ from anonymous methods because of the type inference, and its ability to be

    easily transformed into delegates or expression trees. We learned the parameter restrictions of lambda expressions and

    how to write an expression from scratch and compile it to a delegate and vice versa.

    History

    10 March, 2008: Article posted

    12 March, 2008: Article updated

    License

    This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    About the Author

    Article Top

    Comments and Discussions

    You must Sign Into use this message board.

    Profile popups Spacing Compact Noise High Layout Open All Per page 50 Update

    First Prev Next

    Shahriar_cse 11-Oct-13 9:30

    Nice article

    Sign In View Thread Permalink

    ioan.bucur 12-Aug-13 21:15

    I found out new things about lambda expression limitations. Thanks!

    PDF Viewer for .NETgdpicture.com

    Display PDF in your application using vb.net or C#. Royalty free !

    nice

    My vote of 5

    http://www.googleadservices.com/pagead/aclk?sa=L&ai=Csei0jIZOU_GbGYTv-gagroD4DruynZsE056coYQBhpKifhABIK2CwShQuuPshgJg_dqxhLAToAHp8ef8A8gBAakCpRZFJM43tz7gAgCoAwGqBMYBT9C_S2XpofirzXqqxN1b_LnAfV0T_vg2vI0s8UGkIYXGKorTMKVmdxWkWSt9vN7yHjhVnYwbGX1A1kAquDen0SpZOUYK1IYVvULIGCYEE12oBEBKsdoLN_RohM0cPeduknWo4JLkT0xq3ERemq9Ip_jiHkpjdy-wYk7KoSzR10pT2fjSKJ4uKKRSGaQ10VsMFh1U1TmknIcdwaaLIeSZg6D6LZ_2j1lvxxKGcFJLeyasp9vTXNqsdjRXUssrQ_aK3dApudKM4AQBiAYBgAf_jZgD&num=1&cid=5GgGO6WAAdulbUdUjq7eGEOo&sig=AOD64_1WOIiwXt7V4CcHZ2Q402vMcewtgA&client=ca-pub-8472437385854639&adurl=http://www.gdpicture.com/solutions/PDF-Viewer.phphttp://www.googleadservices.com/pagead/aclk?sa=L&ai=Csei0jIZOU_GbGYTv-gagroD4DruynZsE056coYQBhpKifhABIK2CwShQuuPshgJg_dqxhLAToAHp8ef8A8gBAakCpRZFJM43tz7gAgCoAwGqBMYBT9C_S2XpofirzXqqxN1b_LnAfV0T_vg2vI0s8UGkIYXGKorTMKVmdxWkWSt9vN7yHjhVnYwbGX1A1kAquDen0SpZOUYK1IYVvULIGCYEE12oBEBKsdoLN_RohM0cPeduknWo4JLkT0xq3ERemq9Ip_jiHkpjdy-wYk7KoSzR10pT2fjSKJ4uKKRSGaQ10VsMFh1U1TmknIcdwaaLIeSZg6D6LZ_2j1lvxxKGcFJLeyasp9vTXNqsdjRXUssrQ_aK3dApudKM4AQBiAYBgAf_jZgD&num=1&cid=5GgGO6WAAdulbUdUjq7eGEOo&sig=AOD64_1WOIiwXt7V4CcHZ2Q402vMcewtgA&client=ca-pub-8472437385854639&adurl=http://www.gdpicture.com/solutions/PDF-Viewer.phphttp://www.googleadservices.com/pagead/aclk?sa=L&ai=Csei0jIZOU_GbGYTv-gagroD4DruynZsE056coYQBhpKifhABIK2CwShQuuPshgJg_dqxhLAToAHp8ef8A8gBAakCpRZFJM43tz7gAgCoAwGqBMYBT9C_S2XpofirzXqqxN1b_LnAfV0T_vg2vI0s8UGkIYXGKorTMKVmdxWkWSt9vN7yHjhVnYwbGX1A1kAquDen0SpZOUYK1IYVvULIGCYEE12oBEBKsdoLN_RohM0cPeduknWo4JLkT0xq3ERemq9Ip_jiHkpjdy-wYk7KoSzR10pT2fjSKJ4uKKRSGaQ10VsMFh1U1TmknIcdwaaLIeSZg6D6LZ_2j1lvxxKGcFJLeyasp9vTXNqsdjRXUssrQ_aK3dApudKM4AQBiAYBgAf_jZgD&num=1&cid=5GgGO6WAAdulbUdUjq7eGEOo&sig=AOD64_1WOIiwXt7V4CcHZ2Q402vMcewtgA&client=ca-pub-8472437385854639&adurl=http://www.gdpicture.com/solutions/PDF-Viewer.phphttp://www.googleadservices.com/pagead/aclk?sa=L&ai=Csei0jIZOU_GbGYTv-gagroD4DruynZsE056coYQBhpKifhABIK2CwShQuuPshgJg_dqxhLAToAHp8ef8A8gBAakCpRZFJM43tz7gAgCoAwGqBMYBT9C_S2XpofirzXqqxN1b_LnAfV0T_vg2vI0s8UGkIYXGKorTMKVmdxWkWSt9vN7yHjhVnYwbGX1A1kAquDen0SpZOUYK1IYVvULIGCYEE12oBEBKsdoLN_RohM0cPeduknWo4JLkT0xq3ERemq9Ip_jiHkpjdy-wYk7KoSzR10pT2fjSKJ4uKKRSGaQ10VsMFh1U1TmknIcdwaaLIeSZg6D6LZ_2j1lvxxKGcFJLeyasp9vTXNqsdjRXUssrQ_aK3dApudKM4AQBiAYBgAf_jZgD&num=1&cid=5GgGO6WAAdulbUdUjq7eGEOo&sig=AOD64_1WOIiwXt7V4CcHZ2Q402vMcewtgA&client=ca-pub-8472437385854639&adurl=http://www.gdpicture.com/solutions/PDF-Viewer.phphttp://www.codeproject.com/script/Membership/View.aspx?mid=1505504http://www.codeproject.com/Messages/4678633/nice.aspxhttp://www.codeproject.com/Articles/24255/Exploring-Lambda-Expression-in-C?fid=1094326&df=90&mpp=50&sort=Position&spc=Compact&tid=4678633http://www.codeproject.com/script/Membership/LogOn.aspx?rp=%2fArticles%2f24255%2fExploring-Lambda-Expression-in-Chttp://www.codeproject.com/script/Membership/View.aspx?mid=8787781https://www.codeproject.com/script/Membership/LogOn.aspx?rp=%2fArticles%2f24255%2fExploring-Lambda-Expression-in-C%3ffid%3d1094326%26df%3d90%26mpp%3d50%26noise%3d2%26prof%3dTrue%26sort%3dPosition%26view%3dExpanded%26spc%3dCompacthttp://-/?-http://www.codeproject.com/info/cpol10.aspxhttp://www.codeproject.com/Members/Zeeshan-Jafar-Hirani