Skip to content

Default lambda parameters C# 12.0code reduction

Allow a lambda's parameters to specify default values.

Optional arguments C# 4.0 allows parameters to a method to assume a default in the absence of an explicit passed value.

C# 12.0 extends this to lambda expressions C# 3.0.

Code

C#
var shipOrder = (int x, int y = 1) => x + y;
C#
var increment = (int x, int y) => x + y;
var incrementBy1 = (int x) => increment(x, 1);

More information