ParseDouble() static private method

static private ParseDouble ( String value, NumberStyles options, NumberFormatInfo numfmt ) : Double
value String
options NumberStyles
numfmt NumberFormatInfo
return Double
Ejemplo n.º 1
0
        // Parses a double from a String in the given style.  If
        // a NumberFormatInfo isn't specified, the current culture's
        // NumberFormatInfo is assumed.
        //
        // This method will not throw an OverflowException, but will return
        // PositiveInfinity or NegativeInfinity for a number that is too
        // large or too small.
        //
        /// <include file='doc\Double.uex' path='docs/doc[@for="Double.Parse3"]/*' />
        public static double Parse(String s, NumberStyles style, IFormatProvider provider)
        {
            NumberFormatInfo info = NumberFormatInfo.GetInstance(provider);

            try {
                return(Number.ParseDouble(s, style, info));
            } catch (FormatException) {
                //If we caught a FormatException, it may be from one of our special strings.
                //Check the three with which we're concerned and rethrow if it's not one of
                //those strings.
                String sTrim = s.Trim();
                if (sTrim.Equals(info.PositiveInfinitySymbol))
                {
                    return(PositiveInfinity);
                }
                if (sTrim.Equals(info.NegativeInfinitySymbol))
                {
                    return(NegativeInfinity);
                }
                if (sTrim.Equals(info.NaNSymbol))
                {
                    return(NaN);
                }
                //Rethrow the previous exception;
                throw;
            }
        }
Ejemplo n.º 2
0
 public static double Parse(string s, IFormatProvider?provider)
 {
     if (s == null)
     {
         ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s);
     }
     return(Number.ParseDouble(s, NumberStyles.Float | NumberStyles.AllowThousands, NumberFormatInfo.GetInstance(provider)));
 }
Ejemplo n.º 3
0
 public static double Parse(string s)
 {
     if (s == null)
     {
         ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s);
     }
     return(Number.ParseDouble(s, NumberStyles.Float | NumberStyles.AllowThousands, NumberFormatInfo.CurrentInfo));
 }
Ejemplo n.º 4
0
 public static double Parse(string s, NumberStyles style, IFormatProvider?provider)
 {
     NumberFormatInfo.ValidateParseStyleFloatingPoint(style);
     if (s == null)
     {
         ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s);
     }
     return(Number.ParseDouble(s, style, NumberFormatInfo.GetInstance(provider)));
 }
Ejemplo n.º 5
0
 public static double Parse(string s, NumberStyles style)
 {
     NumberFormatInfo.ValidateParseStyleFloatingPoint(style);
     if (s == null)
     {
         ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s);
     }
     return(Number.ParseDouble(s, style, NumberFormatInfo.CurrentInfo));
 }
Ejemplo n.º 6
0
 private static double Parse(string s, NumberStyles style, NumberFormatInfo info)
 {
     try
     {
         return(Number.ParseDouble(s, style, info));
     }
     catch (FormatException)
     {
         string str = s.Trim();
         if (str.Equals(info.PositiveInfinitySymbol))
         {
             return(PositiveInfinity);
         }
         if (str.Equals(info.NegativeInfinitySymbol))
         {
             return(NegativeInfinity);
         }
         if (!str.Equals(info.NaNSymbol))
         {
             throw;
         }
         return(NaN);
     }
 }
Ejemplo n.º 7
0
        // Parses a double from a String in the given style.  If
        // a NumberFormatInfo isn't specified, the current culture's
        // NumberFormatInfo is assumed.
        //
        // This method will not throw an OverflowException, but will return
        // PositiveInfinity or NegativeInfinity for a number that is too
        // large or too small.

        public static double Parse(ReadOnlySpan <char> s, NumberStyles style = NumberStyles.Float | NumberStyles.AllowThousands, IFormatProvider?provider = null)
        {
            NumberFormatInfo.ValidateParseStyleFloatingPoint(style);
            return(Number.ParseDouble(s, style, NumberFormatInfo.GetInstance(provider)));
        }
Ejemplo n.º 8
0
 // Parses a double from a String in the given style.  If
 // a NumberFormatInfo isn't specified, the current culture's
 // NumberFormatInfo is assumed.
 //
 // This method will not throw an OverflowException, but will return
 // PositiveInfinity or NegativeInfinity for a number that is too
 // large or too small.
 //
 private static double Parse(String s, NumberStyles style, NumberFormatInfo info)
 {
     return(Number.ParseDouble(s, style, info));
 }
 public static double Parse(string s, NumberStyles style, IFormatProvider provider)
 {
     NumberFormatInfo2.ValidateParseStyleFloatingPoint(style);
     return(Number.ParseDouble(s, style, NumberFormatInfo.GetInstance(provider)));
 }
Ejemplo n.º 10
0
 public static double Parse(string s, NumberStyles style)
 {
     NumberFormatInfo2.ValidateParseStyleFloatingPoint(style);
     return(Number.ParseDouble(s, style, NumberFormatInfo.CurrentInfo));
 }
Ejemplo n.º 11
0
 public static double Parse(string s, IFormatProvider provider)
 {
     return(Number.ParseDouble(s, NumberStyles.Float | NumberStyles.AllowThousands, NumberFormatInfo.GetInstance(provider)));
 }
Ejemplo n.º 12
0
 public static double Parse(string s)
 {
     return(Number.ParseDouble(s, NumberStyles.Float | NumberStyles.AllowThousands, NumberFormatInfo.CurrentInfo));
 }