Expression Lambda versus Statement Lambda

前端 未结 8 897
北荒
北荒 2020-12-30 02:02

Fundamentally, is there any difference between a single-line expression lambda and a statement lambda? Take the following code, for example:

private delegate         


        
8条回答
  •  天涯浪人
    2020-12-30 02:35

    If the delegate returns a value, return is necessary in statement lambda as follows.

            Func foo = (x, y) => { return x == y; };
            Func goo = (x, y) => x == y;
    

提交回复
热议问题