how add zeros to numbers...

G

Guest

hello...
i have a number which i want to add 0's to it..

e.g.
int number = 002;
number = number + 1 and it should return me e.g. 3.
how can i keep the 002 and allow it to return 003 instead of just 3?

thanks.
 
K

Ken Cox [Microsoft MVP]

Hi Asha,

Try this?

int number = 002;
number = number + 1;
Label1.Text=number.ToString("000");

Ken
Microsoft MVP [ASP.NET]
Toronto
 
K

Kevin Spencer

You don't have a number. You have a string. In numbers, 002 IS 2. There are
no leading zeros. There are only bits. A 32-bit integer, for example, has 32
bits, all of which are either 1 or 0.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top