由 lambda 分配給委託

Lambdas 可用於建立分配給委託的匿名方法:

Func<int,int> addOne = x => x+1;

請注意,以這種方式建立變數時需要顯式宣告型別:

var addOne = x => x+1; // Does not work