我想用数学来做。圆的函数


当前回答

这是为了在c#中四舍五入到小数点后2位:

label8.Text = valor_cuota .ToString("N2") ;

在VB。NET:

 Imports System.Math
 round(label8.text,2)

其他回答

下面是一些例子:

decimal a = 1.994444M;

Math.Round(a, 2); //returns 1.99

decimal b = 1.995555M;

Math.Round(b, 2); //returns 2.00

你可能还想看看银行家的四舍五入/四舍五入到偶数与以下过载:

Math.Round(a, 2, MidpointRounding.ToEven);

这里有更多的信息。

这是为了在c#中四舍五入到小数点后2位:

label8.Text = valor_cuota .ToString("N2") ;

在VB。NET:

 Imports System.Math
 round(label8.text,2)

试试这个:

twoDec = Math.Round(val, 2)

字符串a = "10.65678";

decimal d = Math.Round(Convert.ToDouble(a.ToString()),2)

你可能需要检查的一件事是数学的舍入机制。轮:

http://msdn.microsoft.com/en-us/library/system.midpointrounding.aspx

除此之外,我推荐数学。Round(inputnumber, numberOfPlaces)接近*100/100,因为它更干净。