By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,946 Members | 744 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,946 IT Pros & Developers. It's quick & easy.

how add zeros to numbers...

P: n/a
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.

Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi Asha,

Try this?

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

Ken
Microsoft MVP [ASP.NET]
Toronto

"Asha" <As**@discussions.microsoft.com> wrote in message
news:B9**********************************@microsof t.com...
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.


Nov 19 '05 #2

P: n/a
Here's a reference for the format strings:

http://msdn.microsoft.com/library/de...putexample.asp
"Asha" <As**@discussions.microsoft.com> wrote in message
news:B9**********************************@microsof t.com...
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.


Nov 19 '05 #3

P: n/a
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.

"Asha" <As**@discussions.microsoft.com> wrote in message
news:B9**********************************@microsof t.com...
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.

Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.