是否可以这样做(或者我可能需要特定版本的 C#)?
Function<int,int,int,int> triSum = (a,b,c) => {return a+b+c;};
var tup = (1,2,3);
triSum(tup); //passing one tuple instead of multiple args
更新:我的意思是传递元组而不是单独的参数。
public void DoWrite(string s1, string s2)
{
Console.WriteLine(s1+s2);
}
public (string,string) GetTuple()
{
//return some of them
}
//few lines later
DoWrite(GetTuple());