static private ParseSingle ( String value, NumberStyles options, NumberFormatInfo numfmt ) : Single | ||
value | String | |
options | NumberStyles | |
numfmt | NumberFormatInfo | |
return | Single |
// Parses a float 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 path='docs/doc[@for="Single.Parse3"]/*' /> public static float Parse(String s, NumberStyles style) { try { return(Number.ParseSingle(s, style)); } 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(NumberFormatInfo.positiveInfinitySymbol)) { return(PositiveInfinity); } if (sTrim.Equals(NumberFormatInfo.negativeInfinitySymbol)) { return(NegativeInfinity); } if (sTrim.Equals(NumberFormatInfo.nanSymbol)) { return(NaN); } //Rethrow the previous exception; throw; } }
public static float Parse(String s, IFormatProvider provider) { if (s == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); } return(Number.ParseSingle(s, NumberStyles.Float | NumberStyles.AllowThousands, NumberFormatInfo.GetInstance(provider))); }
// Parses a float 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 float Parse(String s) { if (s == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); } return(Number.ParseSingle(s, NumberStyles.Float | NumberStyles.AllowThousands, NumberFormatInfo.CurrentInfo)); }
public static float Parse(String s, NumberStyles style, IFormatProvider provider) { NumberFormatInfo.ValidateParseStyleFloatingPoint(style); if (s == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); } return(Number.ParseSingle(s, style, NumberFormatInfo.GetInstance(provider))); }
public static float Parse(string s, NumberStyles style) { NumberFormatInfo.ValidateParseStyleFloatingPoint(style); if (s == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); } return(Number.ParseSingle(s, style, NumberFormatInfo.CurrentInfo)); }
private static float Parse(string s, NumberStyles style, NumberFormatInfo info) { try { return(Number.ParseSingle(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); } }
private static float Parse(String s, NumberStyles style, NumberFormatInfo info) { return(Number.ParseSingle(s, style, info)); }
public static float Parse(ReadOnlySpan <char> s, NumberStyles style = NumberStyles.Float | NumberStyles.AllowThousands, IFormatProvider provider = null) { NumberFormatInfo.ValidateParseStyleFloatingPoint(style); return(Number.ParseSingle(s, style, NumberFormatInfo.GetInstance(provider))); }
public static float Parse(string s, NumberStyles style, IFormatProvider provider) { NumberFormatInfo2.ValidateParseStyleFloatingPoint(style); return(Number.ParseSingle(s, style, NumberFormatInfo.GetInstance(provider))); }
public static float Parse(string s, NumberStyles style) { NumberFormatInfo2.ValidateParseStyleFloatingPoint(style); return(Number.ParseSingle(s, style, NumberFormatInfo.CurrentInfo)); }
public static float Parse(string s, IFormatProvider provider) { return(Number.ParseSingle(s, NumberStyles.Float | NumberStyles.AllowThousands, NumberFormatInfo.GetInstance(provider))); }
public static float Parse(string s) { return(Number.ParseSingle(s, NumberStyles.Float | NumberStyles.AllowThousands, NumberFormatInfo.CurrentInfo)); }