Click here to Skip to main content
15,944,837 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted

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


See here:

http://www.csharp-examples.net/string-format-int[^]
 
Share this answer
 
v2
Comments
Hiren solanki 2-Nov-10 8:47am    
Good Answer.
C#
string s = 584.ToString().PadLeft(9, '0');
 
Share this answer
 
Comments
RaviRanjanKr 2-Nov-10 9:21am    
My Vote 5,good one
shakil0304003 2-Nov-10 10:12am    
Good Answer
See here[^].
 
Share this answer
 
Comments
Hiren solanki 2-Nov-10 8:51am    
It's better to use answered by JF2015.

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