Cat <(E-Mail Removed)> wrote:
> I have an integer whose value varies from 0 to 9999.
> I want to print it in a four-digit format.
> Like,
> 0000
> 0001
> 0002
> ....
> 9998
> 9999
> I tried String.Format("{0:####}",val), but it didn't work. How can I do
> this? Thanks.
Try {0:0000} as the format string instead. Alternatively (and slightly
more compactly), you can call ToString directly on val:
val.ToString("0000")
--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet Blog:
http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too