XmlConvert.ToString Method (Decimal)
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Assembly: System.Xml (in System.Xml.dll)
Parameters
- value
- Type: System.Decimal
The value to convert.
//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) 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 } // Display the output to the TextBlock control OutputTextBlock.Text = output.ToString();
Show: