Perl有能力:
my ($a,$b,$c,$d) = foo();
Run Code Online (Sandbox Code Playgroud)
其中foo返回4个变量,而不是在同一时间进行指定一个.C#中有类似的东西吗?
不,基本上.选项:
object[] values = foo();
int a = (int)values[0];
string b = (string)values[1];
// etc
Run Code Online (Sandbox Code Playgroud)
要么:
var result = foo();
// then access result.Something, result.SomethingElse etc
Run Code Online (Sandbox Code Playgroud)
要么:
int a;
string b;
float c; // using different types to show worst case
var d = foo(out a, out b, out c); // THIS WILL CONFUSE PEOPLE and is not a
// recommendation
Run Code Online (Sandbox Code Playgroud)