Lambda 表达式作为委托初始化的简写
public delegate int ModifyInt(int input);
ModifyInt multiplyByTwo = x => x * 2;
上面的 Lambda 表达式语法等效于以下详细代码:
public delegate int ModifyInt(int input);
ModifyInt multiplyByTwo = delegate(int x){
return x * 2;
};
public delegate int ModifyInt(int input);
ModifyInt multiplyByTwo = x => x * 2;
上面的 Lambda 表达式语法等效于以下详细代码:
public delegate int ModifyInt(int input);
ModifyInt multiplyByTwo = delegate(int x){
return x * 2;
};