12,395,645 members (61,113 online)
Rate this:
See more:
Hello,

I have a double, and I want to change it to a string, like this:

```double value;
string myString = value.toString();```

When value is a number with less than 4 digits after the point, it works fine.
For example,
if value is 0, myString will be 0.
if value is 0.01, myString will be 0.01.

But in cases when value has 4 or more digits after the point, myString is created with a floating point (for example, 1E-05).

I want myString to be created in a format of 0.0000000X for any number of digits after the point, and never use the 1E-0X method.
I also want to keep myString as short as possible, for exmaple when the value is 0, i want myString to be 0 (and not 0.000000).

How can I do it?
Thanks
Posted 11-Dec-12 20:04pm

What are you talking about? "value.toString()" cannot even compile...
--SA
user_code 12-Dec-12 2:22am

Of course it can, and it compiles..

Rate this:

## Solution 2

```double value;
decimal d= Convert.ToDecimal(value);
string myString = d.toString();```
Rate this:

## Solution 3

Go through the following MSDN link. All the required formats are explained.
http://msdn.microsoft.com/en-us/library/dwhawy9k(VS.100).aspx[^]
Rate this:

Rate this:

## Solution 1

```double d = 8.7888888888888888;
float f = float.Parse(d.ToString());
string str = f.ToString();

richTextBox1.Text = str.Split('.')[0].ToString();```

Top Experts
Last 24hrsThis month
 Jochen Arndt 195 OriginalGriff 195 Richard MacCutchan 80 ppolymorphe 70 Richard Deeming 65
 OriginalGriff 6,038 Karthik Bangalore 2,382 ppolymorphe 2,360 F-ES Sitecore 1,877 Richard MacCutchan 1,717