整数值长度6(123456)它固定为leangth,但我们有2位数,如(12)值,所以我想要结果(000012) [英] Interger value length 6 (123456) it is fixed leangth,but we have 2 digits like (12) value, so i want result (000012)

查看:52
本文介绍了整数值长度6(123456)它固定为leangth,但我们有2位数,如(12)值,所以我想要结果(000012)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

这是Bharat



在windows应用程序中我有一个整数值的问题,这里我有一个intiger值,长度是6位数像(123456)我修复了这个,但员工ID是4位数,如(1234),所以我想结果喜欢(001234)。所以我想帮忙..



请......



谢谢

Bharath kumar

Hello
This is Bharat

In windows application i have a problem with integer value,here i have an intiger value, length is 6 digits like(123456) i fixed this,but employee id is 4 digits like(1234), so i want result to like (001234). so i want help..

please......

Thank you
Bharath kumar

推荐答案

试试这个



Try this

int number = 1234;
//D6 = pad with 000000
string outputValue = String.Format("{0:D6}", number);


显示值时:

< a href =http://msdn.microsoft.com/en-us/library/system.string.format.aspx> String.Format [ ^ ]



String.PadLeft [ ^ ]
When you display the value:
String.Format[^]
or
String.PadLeft[^]


HI,



一旦获得解决方案,请查看以下链接。



强制整数至少2位数[关闭]



10以下的int值转换为字符串两位数字



自定义数字格式



谢谢


Checkout the following link once you will get your solution.

Force an Integer To Be At Least 2 Digits Long [closed]

int value under 10 Convert to string two digit number

Custom numeric formats

Thanks


这篇关于整数值长度6(123456)它固定为leangth,但我们有2位数,如(12)值,所以我想要结果(000012)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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