将一个整数除以 100 并得到值到小数点后两位?

use*_*676 -3 c# rounding

String在 a 中有金额TextBox,我想除以 100。

该值应四舍五入到两位小数。我试过了,但没有得到正确的值。

这是我尝试过的:

6766/100 = 67.66
47/100 = .47
98/100 = .98
Run Code Online (Sandbox Code Playgroud)

Ehs*_*san 5

使用Math.Round。这个例子应该让你开始

string txtText = "78907";

double inputValue;

if (double.TryParse(txtText, out inputValue))
   double result = Math.Round(inputValue / 100, 2);
Run Code Online (Sandbox Code Playgroud)

输出: 789.07