System.Xml.XmlReader.ReadContentAsDouble

Overview

The ReadContentAsDouble method of the System.Xml.XmlReader class reads the next node's value as a double and returns it. This method is typically used when the XML content represents numeric values that should be interpreted as doubles.

Syntax


public static double ReadContentAsDouble(XmlReader reader)

Parameters

reader: An XmlReader object representing the XML document to read from.

Returns

A double representing the value of the current node, or 0 if the current node does not contain a value that can be converted to a double.

Usage Example

The following example demonstrates how to use ReadContentAsDouble to parse a double value from an XML document.


using System.Xml;

// ... (Assume you have an XmlReader object named 'reader')

double value = reader.ReadContentAsDouble();

if (value != 0)
{
    Console.WriteLine("Value: " + value);
}
else
{
    Console.WriteLine("No double value found in the current node.");
}

For more information on XmlReader and its various methods, please refer to the System.Xml.XmlReader documentation.