Lambda expression for multiple parameters

后端 未结 3 918
一向
一向 2021-02-03 21:27

I understand a lambda expression is in essence an inline delegate declaration to prevent the extra step

example

delegate int Square(int x)
public class          


        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-03 22:09

    You must understand the Func behavior, where the last parameter is always the output or result

    Func<1, 2, outPut>

    Func Add = (x, y) => x + y;
    
    Func diff = (x, y) => x - y;
    
    Func multi = (x, y) => x * y;
    

提交回复
热议问题