You want to say
this(t => { })
Think of it like this. You need t => anonymous-expression-body
. In this case, anonymous-expression-body
is an expression
or a block
. You can't have an empty expression so you can't indicate an empty method body with an expression
. Therefore, you have to use a block
in which case you can say { }
to indicate the a block
has an empty statement-list
and is therefore the empty body.
For details, see the grammar specification, appendix B.
And here's another way to think of it, which is a way that you could use to discover this for yourself. An Action
is a method that takes in a T
and returns void
. You can define an Action
via an non-anonymous method or via an anonymous method. You are trying to figure out how to do it using an anonymous method (or rather, a very special anonymous method, namely a lambda expression). If you wanted to do this via a non-anonymous method you would say
private void MyAction(T t) { }
and then you could say
this(MyAction)
which uses the concept of a method group. But now you want to translate this to a lambda expression. So, let's just take that method body and make it a lambda expression. Therefore, we throw away the private void MyAction(T t)
and replace it with t =>
and copy verbatim the method body { }
.
this(t => { })
Boom.