static private ParseDouble ( String value, NumberStyles options, NumberFormatInfo numfmt ) : Double | ||
value | String | |
options | NumberStyles | |
numfmt | NumberFormatInfo | |
return | Double |
// 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; } }
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))); }
public static double Parse(string s) { if (s == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); } return(Number.ParseDouble(s, NumberStyles.Float | NumberStyles.AllowThousands, NumberFormatInfo.CurrentInfo)); }
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))); }
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)); }
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); } }
// 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))); }
// 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))); }
public static double Parse(string s, NumberStyles style) { NumberFormatInfo2.ValidateParseStyleFloatingPoint(style); return(Number.ParseDouble(s, style, NumberFormatInfo.CurrentInfo)); }
public static double Parse(string s, IFormatProvider provider) { return(Number.ParseDouble(s, NumberStyles.Float | NumberStyles.AllowThousands, NumberFormatInfo.GetInstance(provider))); }
public static double Parse(string s) { return(Number.ParseDouble(s, NumberStyles.Float | NumberStyles.AllowThousands, NumberFormatInfo.CurrentInfo)); }