【发布时间】:2014-02-19 15:26:00
【问题描述】:
在 C# 中,使用双数 191.5(示例),我想创建一个字符串:
- 正好有 10 个字符
- 向左填充 0
- 包括点字符 (.)
- 只包含 1 个小数
我的代码:
strOut += SubString(10, string.Format("{0:0000000000}", 191.5));
我的代码的问题在于:
- 循环(我不想要)
- 它会擦除小数点
我的代码输出:
0000000192
我需要的输出:
00000191.5
【问题讨论】:
-
我已经编辑了你的标题。请参阅“Should questions include “tags” in their titles?”,其中的共识是“不,他们不应该”。
-
如果您的
double长度超过 10 个字符会怎样?
标签: c# double decimal rounding string.format