的ToString()preserve前导零 [英] .tostring() preserve leading zeros
本文介绍了的ToString()preserve前导零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
转换对象的ToString()删除前导零。对象是不固定的长度,所以我不能做object.tostring(0000000),其中零的个数重新presents固定长度。
一个例子对象值为0357时,我将其转换对象的ToString就变成了357。
是否有保留,其长度是不知道的前导零的方法?
解决方案
object.ToString(D7)
其中, 7
重新presents的数字,以填补数。
357 == 0000357
Converting an object .tostring() removes the leading zeros. The object is not a fixed length, so I can't do object.tostring("0000000") where the number of zeros represents the fixed length.
An example object value is "0357" when I convert that object .tostring it becomes "357".
Is there a method for keeping the leading zeros where the length is not known?
解决方案
object.ToString("D7")
Where 7
represents the number of digits to fill.
357 == 0000357
这篇关于的ToString()preserve前导零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文