在C#中,如果双数大于零(例如:0.0000456),则显示为4.56E-05。但我想显示为0.0000456。反正有没有改变显示格式?请帮忙!
答案 0 :(得分:0)
使用格式设置来完成此操作。
double test = 0.0000456;
Console.WriteLine(test);
Console.WriteLine("{0:F7}", test);
Console.ReadKey();
<强>输出强>
4.56E-05
0.0000456
<强>最高强>
double test =
0.00000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000001;
Console.WriteLine(test);
Console.WriteLine("{0:F99}", test);
Console.ReadKey();
<强>输出强>
1E-99
0.00000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000001;