Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Convert.ToString Method (Double)

Converts the value of the specified double-precision floating point number to its equivalent String representation.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)
public static string ToString(
	double value
)

Parameters

value
Type: System.Double
A double-precision floating point number.

Return Value

Type: System.String
The String equivalent of the value of value.

This implementation is identical to Double.ToString.

The following code sample illustrates the conversion of a Double to a String, using ToString.


public void ConvertDoubleString(double doubleVal)
{
   string stringVal;

   // A conversion from Double to string cannot overflow.       
   stringVal = System.Convert.ToString(doubleVal);
   outputBlock.Text += String.Format("{0} as a string is: {1}",
      doubleVal, stringVal) + "\n";

   try
   {
      doubleVal = System.Convert.ToDouble(stringVal);
      outputBlock.Text += String.Format("{0} as a double is: {1}",
         stringVal, doubleVal) + "\n";
   }
   catch (System.OverflowException)
   {
      outputBlock.Text += String.Format(
         "Conversion from string-to-double overflowed.") + "\n";
   }
   catch (System.FormatException)
   {
      outputBlock.Text += String.Format(
         "The string was not formatted as a double.") + "\n";
   }
   catch (System.ArgumentException)
   {
      outputBlock.Text += String.Format(
         "The string pointed to null.") + "\n";
   }
}


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.