Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 5th, 2007, 11:05 AM   #1
Arla
Hobbyist Programmer
 
Arla's Avatar
 
Join Date: Mar 2005
Posts: 227
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
Old Nov 5th, 2007, 11:08 AM   #2
Arla
Hobbyist Programmer
 
Arla's Avatar
 
Join Date: Mar 2005
Posts: 227
Rep Power: 4 Arla is on a distinguished road
Re: String formatting

Knew I was being thick...

String.Format("{0:D8}", i)

This did it.
Arla is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
An Attempt at a DBMS grimpirate PHP 8 Apr 17th, 2007 1:01 PM
Throwing an exception when using string constructor csrocker101 C# 3 Apr 8th, 2007 2:04 PM
Help with breaking apart a string csrocker101 C# 6 Apr 6th, 2007 7:50 AM
Function Parameters grimpirate PHP 10 Mar 14th, 2007 6:55 PM
Problems with String to MD5 Conversion emdiesse Visual Basic .NET 0 Feb 2nd, 2006 10:25 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:56 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC