String.Format 格式不正确
String.Format is not formatting correctly
我有以下代码,但无法正确格式化。它忽略了我的格式。例如 sOrderNo 不是 10 个零,它只是 1 个零。我在这里做错了什么?
sKey = String.Format("{0:D10} {1:00} {2} {3} {4} {5} {6} {7} {8:000.0000} {9:000.0000}",
sOrderNo, sItem, sSpecies, sSpSort, rs.Fields("UsageCode").Value,
rs.Fields("Cure").Value, sGrade, sSurface,
rs.Fields("TkFactor").Value,rs.Fields("WdFactor").Value)
sOrderNo is not 10 zeros,
所需的格式字符串是 D10
,而不是 10D
。闲置古玩:the documentation implies only up to D9 is possible, but it works with 10 and all the way to 99 even
Console.WriteLine(string.Format("Hello World {0:D99}", 12345));
我有以下代码,但无法正确格式化。它忽略了我的格式。例如 sOrderNo 不是 10 个零,它只是 1 个零。我在这里做错了什么?
sKey = String.Format("{0:D10} {1:00} {2} {3} {4} {5} {6} {7} {8:000.0000} {9:000.0000}",
sOrderNo, sItem, sSpecies, sSpSort, rs.Fields("UsageCode").Value,
rs.Fields("Cure").Value, sGrade, sSurface,
rs.Fields("TkFactor").Value,rs.Fields("WdFactor").Value)
sOrderNo is not 10 zeros,
所需的格式字符串是 D10
,而不是 10D
。闲置古玩:the documentation implies only up to D9 is possible, but it works with 10 and all the way to 99 even
Console.WriteLine(string.Format("Hello World {0:D99}", 12345));