Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

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
)

Parameters

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.

The following example, converts data types to string and then writes the information out to the console.

#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{

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

   //Create a writer that outputs to the console.
   XmlTextWriter^ writer = gcnew XmlTextWriter( Console::Out );
   writer->Formatting = Formatting::Indented;

   //Write an element (this one is the root)
   writer->WriteStartElement( "order" );

   //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
   writer->WriteEndElement();

   //Write the XML and close the writer
   writer->Close();
}

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show:
© 2017 Microsoft