代码之家  ›  专栏  ›  技术社区  ›  redoc01

如何调用传入lambda表达式的函数?

  •  -5
  • redoc01  · 技术社区  · 6 月前

    如果我有这样的东西:

    public void add(func<string, string> 
    val)
    {
         textval = val; // val should be hello
    }
    

    我想调用这个函数

    add((val) => "hello")
    
    1 回复  |  直到 6 月前
        1
  •  0
  •   Yuriy Faktorovich    6 月前
    public void Add(Func<string, string> val)
    {
        var textval = val(""); // textval should be hello
    }