System.Xml.XmlConverter.ToSingle C# (CSharp) Méthode

ToSingle() static public méthode

static public ToSingle ( string value ) : float
value string
Résultat float
        static public float ToSingle(string value)
        {
            try
            {
                return XmlConvert.ToSingle(value);
            }
            catch (ArgumentException exception)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(value, "float", exception));
            }
            catch (FormatException exception)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(value, "float", exception));
            }
            catch (OverflowException exception)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(XmlExceptionHelper.CreateConversionException(value, "float", exception));
            }
        }

Same methods

XmlConverter::ToSingle ( byte buffer, int offset, int count ) : float

Usage Example

Exemple #1
0
        public float ToSingle()
        {
            switch (this.type)
            {
            case ValueHandleType.Single:
                return(this.GetSingle());

            case ValueHandleType.Double:
            {
                double d = this.GetDouble();
                if (((d >= -3.4028234663852886E+38) && (d <= 3.4028234663852886E+38)) || (double.IsInfinity(d) || double.IsNaN(d)))
                {
                    return((float)d);
                }
                break;
            }

            case ValueHandleType.Zero:
                return(0f);

            case ValueHandleType.One:
                return(1f);

            case ValueHandleType.Int8:
                return((float)this.GetInt8());

            case ValueHandleType.Int16:
                return((float)this.GetInt16());

            case ValueHandleType.UTF8:
                return(XmlConverter.ToSingle(this.bufferReader.Buffer, this.offset, this.length));
            }
            return(XmlConverter.ToSingle(this.GetString()));
        }
All Usage Examples Of System.Xml.XmlConverter::ToSingle