我目前在一个小 C# 程序中有以下 longs。long one = 1;long two = 1005;long three = 100000005;long four = 1111112258552;我想将它们格式化为字符串,以便它们的大小是千分之一而不用将值除以一千。例子Input : Output1 0.0011005 1.005100000005 100000.0051111112258552 1111112258.552我尝试过诸如{0:0,000}和 之类的字符串格式,{0:0.000}但都没有提供我想要的结果。我怎样才能达到我所追求的结果?任何提示或指示将不胜感激一些示例代码long one = 1;long two = 1005;long three = 100000005;long four = 1111112258552;string format = "{0:0,000}";string s1 = String.Format(format, one);string s2 = String.Format(format, two);string s3 = String.Format(format, three);string s4 = String.Format(format, four);Console.WriteLine(s1);Console.WriteLine(s2);Console.WriteLine(s3);Console.WriteLine(s4);
1 回答
- 1 回答
- 0 关注
- 96 浏览
添加回答
举报
0/150
提交
取消