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

ReadContentAsDouble() public method

public ReadContentAsDouble ( ) : double
return double
        public virtual double ReadContentAsDouble()
        {
            if (!CanReadContentAs())
            {
                throw CreateReadContentAsException(nameof(ReadContentAsDouble));
            }
            try
            {
                return XmlConvert.ToDouble(InternalReadContentAsString());
            }
            catch (FormatException e)
            {
                throw new XmlException(SR.Xml_ReadContentAsFormatException, "Double", e, this as IXmlLineInfo);
            }
        }

Usage Example

Example #1
0
        public void Restore(XmlReader reader)
        {
            int count = reader.AttributeCount;
            for (int i = 0; i < count; ++i)
            {
                reader.MoveToAttribute(i);
                switch (reader.Name)
                {
                    case "top":
                        Top = reader.ReadContentAsDouble();
                        break;

                    case "left":
                        Left = reader.ReadContentAsDouble();
                        break;

                    case "width":
                        Width = reader.ReadContentAsDouble();
                        break;

                    case "height":
                        Height = reader.ReadContentAsDouble();
                        break;

                    case "state":
                        State = (WindowState) Enum.Parse(typeof (WindowState), reader.Value);
                        break;
                }
            }
        }
All Usage Examples Of System.Xml.XmlReader::ReadContentAsDouble