假设有这样一条记录
public record ExampleRecord(int a, int b);
Run Code Online (Sandbox Code Playgroud)
和一个方法
public int ExampleMethod((int a, int b) t)
{
return t.a + t.b;
}
Run Code Online (Sandbox Code Playgroud)
是否可以执行类似的操作来将记录用作元组参数?
var t = new ExampleRecord(a: 1, b: 2);
ExampleMethod(t);
Run Code Online (Sandbox Code Playgroud)