Is there a better way to express a parameterless lambda than () =>?

后端 未结 4 1083
我寻月下人不归
我寻月下人不归 2020-12-02 17:04

The () seems silly. is there a better way?

For example:

ExternalId.IfNotNullDo(() => ExternalId = ExternalId.Trim());

4条回答
  •  甜味超标
    2020-12-02 17:51

    No, there isn't. Lambda expressions are optimised (in terms of syntax) for the single parameter case.

    I know that the C# team feels your pain, and have tried to find an alternative. Whether there ever will be one or not is a different matter.

提交回复
热议问题