相关疑难解决方法(0)

在C#7中,可以将元组解构为方法参数

比如我有

private void test(Action<ValueTuple<string, int>> fn)
{
    fn(("hello", 10));
}

test(t => 
 {
    var (s, i) = t;
    Console.WriteLine(s);
    Console.WriteLine(i);
});
Run Code Online (Sandbox Code Playgroud)

我想写这样的东西

private void test(Action<ValueTuple<string, int>> fn)
{
    fn(("hello", 10));
}

test((s,i) => 
{
    Console.WriteLine(s);
    Console.WriteLine(i);
});
Run Code Online (Sandbox Code Playgroud)

这有可能用一些正确的表示法吗?

tuples c#-7.0

29
推荐指数
3
解决办法
1万
查看次数

标签 统计

c#-7.0 ×1

tuples ×1