How to format a String into Money - newbie

B

Bob Geltz

This may be a simple question, but I'm new and stumped.
I need to display a string like currency ( $123.00). I cannot find the
correct format call to make it happen. Using C#. Don't care if the $$ is
present or not, need to always display a number to two decimal place
accuracy. Help.

bob.
 
J

JimH

Check out numeric string formatting.

double amt = 1.0 / 3.0;
Console.WriteLine( amt );
Console.WriteLine( amt.ToString("$#,##0.00") );

--Jim
 
N

nickp

Bob, you can also do something as followings, (note the :C in the fomat method)

double d = 2
string s = string.Format("{0:C}", d)

-Nick Parker
 

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

Top