我String在 a 中有金额TextBox,我想除以 100。
该值应四舍五入到两位小数。我试过了,但没有得到正确的值。
这是我尝试过的:
6766/100 = 67.66
47/100 = .47
98/100 = .98
Run Code Online (Sandbox Code Playgroud)
使用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
| 归档时间: |
|
| 查看次数: |
6456 次 |
| 最近记录: |