views:

493

answers:

7

Are there any codes that allow for numerical formatting of data when using string.format?

+5  A: 

Loads, stick string.Format into Google :-)

A quite good tutorial is at http://idunno.org/archive/2004/14/01/122.aspx

Keith
+1  A: 

As Keith said above. The most common one I use is currency:

String.Format("{0:c}", 12000);

Which would output £12,000.00

GateKiller
+3  A: 

Yes, you could format it this way:

string.Format("Format number to: {0 : #.00}", number);
string.Format("Format date to: {0 : MM/dd/yyyy}", date);
Jon Limjap
+2  A: 

There are a number. This MS site is probably the best place to look

KiwiBastard
+2  A: 

Here is another very good reference that compliments what Keith mentioned.

http://www.scribd.com/doc/2547864/msnetformattingstrings

DrZ
+1  A: 

Taking someone else's answer and editing it and marking yourself as the person to answer is NOT COOL IMO.

Rob Cooper
A: 

Apologies. I wrote the question as I found info describing the feature in a book I was reading and I thought it would be good to add to the site so I posted the question but as I was writing the answer lots of you answered for me with some great sites so when I posted my answer it looked as if I had done exactly as robcthegeek described. Sorry if it looked that way and thanks for the great links.

Kievia