.NET Framework - format a double using System.Convert.ToString

Asked By W on 08-Apr-08 12:42 PM
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




parez replied on 10-Apr-08 02:17 AM
double d = 2.34343;

MessageBox.Show(d.ToString("0.00"));
Ignacio Machin ( .NET/ C# MVP ) replied on 10-Apr-08 02:17 AM
do
at

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
W replied on 08-Apr-08 01:41 PM
Thanks!
WJ