Math.Round()。我的数据是 10.17 ,如何四舍五入到 10.50

Math.Round(). My data is 10.17 , how can i round to 10.50

我的数据是10.17,我想在回合后得到10.50。 我使用 totQty = Math.Round(totQty, 1, MidpointRounding.ToEven) 但得到 10.20 的代码。

为此,您可以将您的数字乘以 2,四舍五入后保留 0 位小数,然后除以 2。

double rounded = Math.Ceiling(2 * value) / 2;