[英]Display double value without scientific notation
I have a null able double value which get values from data base.It retrieve value from data base as '1E-08'. 我有一个null的double值,它从数据库中获取值。它从数据库中检索值为'1E-08'。 I want to display the value with out scientific notification (0.00000001)
我想显示没有科学通知的值(0.00000001)
I used the following code. 我使用了以下代码。
double? valueFromDB=1E-08;
string doubleValue=valueFromDB.Value.Value.ToString();
string formatedString=String.Format("{0:N30}", doubleValue);
But the value of formatedString is still 1E-08. 但是formatedString的值仍然是1E-08。
You're calling string.Format
with a string . 你用字符串调用
string.Format
。 That's not going to apply numeric formatting. 这不会应用数字格式。 Try removing the second line:
尝试删除第二行:
double? valueFromDB = 1E-08;
string formattedString = String.Format("{0:N30}", valueFromDB.Value);
Or alternatively, specify the format string in a call to ToString
on the value: 或者,在值上调用
ToString
时指定格式字符串:
double? valueFromDB = 1E-08;
string formattedString = valueFromDB.Value.ToString("N30");
That produces 0.000000010000000000000000000000
for me. 这对我来说就产生了
0.000000010000000000000000000000
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.