System.Xml.XmlReader.ReadContentAsFloat C# (CSharp) Method

ReadContentAsFloat() public method

public ReadContentAsFloat ( ) : float
return float
        public virtual float ReadContentAsFloat()
        {
            if (!CanReadContentAs())
            {
                throw CreateReadContentAsException(nameof(ReadContentAsFloat));
            }
            try
            {
                return XmlConvert.ToSingle(InternalReadContentAsString());
            }
            catch (FormatException e)
            {
                throw new XmlException(SR.Xml_ReadContentAsFormatException, "Float", e, this as IXmlLineInfo);
            }
        }

Usage Example

Example #1
0
 public static Firewall load(XmlReader reader)
 {
     while (reader.Name != "firewall")
         reader.Read();
     var complexity = 0;
     string solution = null;
     var additionalTime = 0.0f;
     if (reader.MoveToAttribute("complexity"))
         complexity = reader.ReadContentAsInt();
     if (reader.MoveToAttribute("solution"))
         solution = reader.ReadContentAsString();
     if (reader.MoveToAttribute("additionalDelay"))
         additionalTime = reader.ReadContentAsFloat();
     return new Firewall(complexity, solution, additionalTime);
 }
All Usage Examples Of System.Xml.XmlReader::ReadContentAsFloat