View Single Post
Old Nov 5th, 2007, 12:05 PM   #1
Arla
Professional Programmer
 
Arla's Avatar
 
Join Date: Mar 2005
Posts: 302
Rep Power: 4 Arla is on a distinguished road
String formatting

Okay, tried a few things and just can't get this to work, what I'm TRYING to do is write out a number formated so it's always the same number of digits, would seem simple but...

I've tried
int i=0;
String.Format("{0:00000000}",i.ToString());

Which just seems to produce a single 0, instead of the 8 I'd like,

I've also tried
int i=0;
String.Format("{0:8}",i.ToString());

Which is better because it puts in all the spaces to make it an 8 character, but still only puts a 0 as the final one, anyone have any ideas? I've tried googling it but a lot of topics explain how to make decimals appear, but not pre-numeric 0's.
Arla is offline   Reply With Quote