Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 555
  • Last Modified:

Formating of int to string in six digit

Hi,

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
0
tia_kamakshi
Asked:
tia_kamakshi
3 Solutions
 
Éric MoreauSenior .Net ConsultantCommented:
YourVariable.ToString("000000")
0
 
makberCommented:
int i = 555; // your integer variable
String.Format("{0:000000}", i);
0
 
Shaun KlineLead Software EngineerCommented:
You can do this by using the PadRight string function:

int value = 120;
value.ToString().PadRight(6, "0");
0
 
ricovoxCommented:
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.
0
 
tia_kamakshiAuthor Commented:
Many Thanks for your support
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now