本文介绍了将0转换为0.0,将1转换为1.0,依此类推的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我的值为0,1,2 ......等等.我将其转换为double后将其四舍五入为小数点后一位.对于十进制后有数字的值,它工作正常,但如果bot正常工作,则可以正常工作数字是100或数字,十进制后没有数字.我想要100的结果是100.0,依此类推.
请帮助
Hi All,
I have values as 0,1,2 ......so on.I have converted it into double after that I round off it to 1 decimal place.It is working fine for values having digit after decimal but bot working fine if the digit is 100 or numbers without having digits after decimal. I want result as 100.0 for 100 and so on.
Please Help
推荐答案
double value = 100;
string valueAsString = value.ToString("N1");
Console.WriteLine (valueAsString);
//Output
//100.0
要显示逗号等,其他Formats
在此处 http://msdn. microsoft.com/en-us/library/dwhawy9k(v=vs.71).aspx [ ^ ].
To show commas etc. other Formats
given here http://msdn.microsoft.com/en-us/library/dwhawy9k(v=vs.71).aspx[^] can be used.
这篇关于将0转换为0.0,将1转换为1.0,依此类推的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!