Number Formatting Question C#

P

probashi

Hi

I want to format numbers with leading zeros

Like:

Input output

0 00
1 01
2 02
10 10
11 11

Thanks
 
K

Kevin Spencer

int i = 0;
string s = i.ToString("00"); // "00"

--
HTH,

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

Karl Seguin

try:
for (int i = 0; i < 100; ++i){
Response.Write(i.ToString("00"));
Response.Write("<Br />");
}

for the win!
 

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

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top