format a double using System.Convert.ToString

  • Thread starter Thread starter WJ
  • Start date Start date
W

WJ

I can use System.Convert.ToString to convert a double to a string, but how do
I format it (say I want to keep two deimals)? Or there is another class that
is I should use? Thanks.

WJ
 
I can use System.Convert.ToString to convert a double to a string, but how do
I format it (say I want to keep two deimals)? Or there is another class that
is I should use? Thanks.

WJ

double d = 2.34343;

MessageBox.Show(d.ToString("0.00"));
 
I can use System.Convert.ToString to convert a double to a string, but howdo
I format it (say I want to keep two deimals)? Or there is another class that
is I should use? Thanks.

WJ

Hi,

In that particular case you can use "0.00" as the format string. Take
a look at "Custom Numeric Format Strings" in MSDN library for more
details
 

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

Back
Top