我正在使用一本书自学......在研究方法时,这本书介绍了从一个方法返回多个值。我已经相应地更改了代码并为元组安装了相关的 Microsoft NuGet 包。当我检查解决方案资源管理器时,我可以看到System.ValueTuple
那里并处于活动状态。但是我的项目没有相应地运行,就好像我没有安装元组包一样..
else if (division.IsChecked.HasValue && division.IsChecked.Value)
{
int division, reminder;
(division, reminder) = Divide(leftHandSide, rightHandSide);
result.Text = $" reminder ";
}
....
private (int, int) Divide(int leftHandSide, int rightHandSide)
{
expression.Text = $" / ";
int division = leftHandSide / rightHandSide;
int reminder = leftHandSide % rightHandSide;
return (division, reminder);
}
private void showResult(int answer) => result.Text = answer.ToString();
}
}