用前导零 [英] Pad with leading zeros
本文介绍了用前导零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何与前导零的我垫我整型变量。
像我有值20的整数ABC,但我希望它是0000020。
code:
quarterlyReportDataCMMS.QRTrailerRecord.FileRecordCount = Convert.ToInt32(refEligibleClaimants.Count);
解决方案
您可以用字符串数据类型做到这一点。使用 PadLeft
方法:
myString.PadLeft(myString.Length + 5,'0');
How can i pad my integer variable with leading zeros. like i have an integer abc with value 20 but i want it to be '0000020'.
Code:
quarterlyReportDataCMMS.QRTrailerRecord.FileRecordCount = Convert.ToInt32(refEligibleClaimants.Count);
解决方案
You can do this with a string datatype. Use the PadLeft
method:
myString.PadLeft(myString.Length + 5, '0');
这篇关于用前导零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文