Formating of int to string in six digit


I am working in web application C# using ASP.net3.5

I wanted to make any integer value to six digit

For example

- If int value is 120 then string value I need is 000120
- If int value is 35 then string value I need is 000035
- If int value is 3532 then string value I need is 003532

Can you please help me in formating this string

Many Thanks
Who is Participating?
makberConnect With a Mentor Commented:
int i = 555; // your integer variable
String.Format("{0:000000}", i);
Éric MoreauConnect With a Mentor Senior .Net ConsultantCommented:
Shaun KlineConnect With a Mentor Lead Software EngineerCommented:
You can do this by using the PadRight string function:

int value = 120;
value.ToString().PadRight(6, "0");
any of the three above answers will work just fine. I suggest you choose the best answer for your particular application and divide the points.
tia_kamakshiAuthor Commented:
Many Thanks for your support
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.