In my c# project a method returns a tuple. Is it possible to deconstruct the result of this method immediately inline and use it as arguments for another method call? I imagine something similar to the ...
operator in JavaScript.
public (string a, string b) GetTupelResult() {
return ("result a", "result b");
}
public void MethodWithTwoStringParameters(string a, string b) {
Debug.WriteLine(a);
Debug.WriteLine(b);
}
public void Main() {
// Deconstruct first, call later ==> WORKS
(string a, string b) = GetTupelResult();
MethodWithTwoStringParameters(a, b);
// Inline solution ==> IS SUCH A THING POSSIBLE?
MethodWithTwoStringParameters(...GetTupelResult());
}
Is there a way to achieve a single-line solution in c# without modifying GetTupelResult
and MethodWithTwoStringParameters
?
I know, that I could modify MethodWithTwoStringParameters
to accept a tupel as parameter, or build a wrapper method/overload. But that is not the point I am trying to make.