如何合并Lambda代理

时间:2012-11-08 15:40:54

标签: c# delegates lambda

我想这样做:

class Foo {

  static Func<string> sRunner;

  Func<string> _runner;

  public Foo(Func<string> runner){

    _runner = runner ?? sRunner ?? () => "Hey!";

  }
}

我在lambda上得到一个“无效表达式”术语。可以内联修复吗?

1 个答案:

答案 0 :(得分:12)

_runner = runner ?? sRunner ?? (() => "Hey!");