本文介绍了在C#中不显示小数点后一位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我的值为2313,546.689,2314.9.
我将这些双精度值四舍五入,但是结果显示为
2313,546.7,2314.9.
但我想要结果为
2313.0,546.7,2314.9.
表示如果no为2313,则应将其显示为2313.0,而不对其进行更改.ToString(0.0)coz我必须使用它进行过滤.
谢谢
Mohd Wasif
Hi All,
I have values as 2313 ,546.689,2314.9.
I have rounded off these double values but the result as displaying as
2313,546.7,2314.9.
but I want result as
2313.0,546.7,2314.9.
means if the no is 2313 then it should be display as 2313.0 without changing it .ToString(0.0) coz I have to use it for filtering.
Thanks
Mohd Wasif
推荐答案
int val = 28;
string formatted = val.ToString("N1");
string a = (2313).ToString("0.0"); // result a=2313.0
祝您编码愉快!
:)
Happy Coding!
:)
这篇关于在C#中不显示小数点后一位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!