XmlConvert.ToString Method (Double)

Converts the Double to a String.

Namespace:  System.Xml
Assembly:  System.Xml (in System.Xml.dll)

public static string ToString(
	double value


Type: System.Double
The value to convert.

Return Value

Type: System.String
A string representation of the Double.

If value is Double.PositiveInfinity or Double.NegativeInfinity, this method returns the string INF or -INF respectively.

//Define the order data.  They will be converted to string 
//before being written out.
Int16 custID = 32632;
String orderID = "367A54";
DateTime orderDate = new DateTime();
orderDate = DateTime.Now;
Double price = 19.95;

StringBuilder output = new StringBuilder();

//Create a writer that outputs to the console.
using (XmlWriter writer = XmlWriter.Create(output))
    //Write an element (this one is the root)

    //Write the order date.
    writer.WriteAttributeString("date", XmlConvert.ToString(orderDate, "yyyy-MM-dd"));

    //Write the order time.
    writer.WriteAttributeString("time", XmlConvert.ToString(orderDate, "HH:mm:ss"));

    //Write the order data.
    writer.WriteElementString("orderID", orderID);
    writer.WriteElementString("custID", XmlConvert.ToString(custID));
    writer.WriteElementString("price", XmlConvert.ToString(price));

    //Write the close tag for the root element

    //Write the XML and close the writer

// Display the output to the TextBlock control
OutputTextBlock.Text = output.ToString();


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.

Community Additions