整数到字符串的转换 [英] Conversion of integer to string

查看:53
本文介绍了整数到字符串的转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

海,
我有1n个整数,例如584.我想使用ToString函数将其转换为字符串,字符串长度为9,前6位应为零.就是这样的输出000000584

Hai,
I have 1n integer For example 584.I want to convert this to string using the ToString function with string length 9 and the first 6 places should be zeros. That is the output is like this 000000584

推荐答案

string str = String.Format("{0:000000000}", 584);          // "000000584"



看到这里:

http://www.csharp-examples.net/string-format-int [ ^ ]



See here:

http://www.csharp-examples.net/string-format-int[^]


string s = 584.ToString().PadLeft(9, '0');


请参见此处 [ ^ ].


这篇关于整数到字符串的转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆