Click here to Skip to main content
15,903,203 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Posted

Try this

C#
int number = 1234;
//D6 = pad with 000000
string outputValue = String.Format("{0:D6}", number);
 
Share this answer
 
Comments
Maciej Los 6-Aug-13 8:02am    
Short and to the point!
+5!
bharat peggem 7-Aug-13 0:41am    
Its working Nice code thank you
When you display the value:
String.Format[^]
or
String.PadLeft[^]
 
Share this answer
 
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900